Layer
El nivel flotante de la página: fijo a la ventana, encima de todo, fuera del desborde de la página. Dialog, Popover y Toast ya viven allí.
import { Layer } from '@sypnia/ui/react'
Una barra encima de la página
Código
import { useState } from 'react';
import { Button, Layer } from '@sypnia/ui/react';
// A bar that floats above everything, fixed to the window, outside the page's overflow.
export default function Floating() {
const [on, setOn] = useState(false);
return (
<>
<Button onClick={() => setOn(!on)}>{on ? 'Hide the bar' : 'Show a floating bar'}</Button>
{on && <Layer style={{ bottom: '1.5rem', left: '50%', translate: '-50% 0' }}><div className="sy-row" style={{ padding: 'var(--s-2) var(--s-3)', background: 'var(--bg-raised)', border: '1px solid var(--line)', borderRadius: 'var(--r-3)', boxShadow: 'var(--shadow-3)' }}><strong>2 selected</strong><Button size="sm" onClick={() => setOn(false)}>Done</Button></div></Layer>}
</>
);
} Cuándo usarlo
Úsalo cuando
- Algo flotante propio que no es un Dialog, un Popover ni un Toast.
No lo uses cuando
- Todo lo que la biblioteca ya hace flotar.
Para todos
- Mover algo a la capa no mueve el foco: manéjalo con FocusScope cuando haga falta.
Props
| Layer | Tipo | Por defecto |
|---|---|---|
className | string | |
inset | boolean | |
style | CSSProperties |