Popover
Un panel pequeño que se abre junto al botón que lo llamó, para un par de campos o unos detalles, sin tapar la página.
import { Popover } from '@sypnia/ui/react'
Un formulario pequeño
Elige un estado: la lista de atrás se actualizaría mientras sigue abierto.
Showing every order.
Código
import { useState } from 'react';
import { Button, Field, NativeSelect, Popover } from '@sypnia/ui/react';
// It opens anchored to its button. Escape or a press outside closes it and the focus returns.
export default function SmallForm() {
const [status, setStatus] = useState('any');
return (
<div className="sy-row">
<Popover label="Filter orders" trigger={<Button icon="filter">Filter</Button>}>
<Field label="Status">
<NativeSelect value={status} onChange={(e) => setStatus(e.target.value)}>
<option value="any">Any status</option><option value="paid">Paid</option><option value="pending">Pending</option><option value="refunded">Refunded</option>
</NativeSelect>
</Field>
<Button size="sm" variant="quiet" onClick={() => setStatus('any')}>Clear the filter</Button>
</Popover>
<span className="sy-text--sm sy-text--soft">{status === 'any' ? 'Showing every order.' : `Showing ${status} orders.`}</span>
</div>
);
} Detalles de una persona
Presiona el nombre.
Código
import { Button, Identity, KeyValue, Popover } from '@sypnia/ui/react';
// More about a thing without leaving the page.
export default function Details() {
return (
<Popover label="About Laura Méndez" trigger={<Button variant="quiet">Laura Méndez</Button>}>
<Identity name="Laura Méndez" meta="laura@northwind.io" />
<KeyValue items={[['Role', 'Owner'], ['Joined', 'November 3, 2026'], ['Last seen', 'Today']]} />
</Popover>
);
} Ubicación
Abajo desde el inicio, abajo desde el final, y arriba.
Código
import { Button, Popover } from '@sypnia/ui/react';
// It opens where you ask and flips by itself when there is no room.
export default function Placement() {
return (
<div className="sy-row sy-row--pairs">
<Popover placement="bottom start" label="Below, from the start" trigger={<Button>Below, start</Button>}><p>Aligned with the start of the button.</p></Popover>
<Popover placement="bottom end" label="Below, from the end" trigger={<Button>Below, end</Button>}><p>Aligned with the end of the button.</p></Popover>
<Popover placement="top" label="Above" trigger={<Button>Above</Button>}><p>Centred above the button.</p></Popover>
</div>
);
} Cuándo usarlo
Úsalo cuando
- Un filtro, un ajuste pequeño, los detalles de una persona o una cosa.
- El contenido es corto y tiene que ver con la cosa a la que está anclado.
No lo uses cuando
- Es una lista de acciones: eso es un Menu, que tiene sus propias teclas.
- Es una línea de texto sobre un botón: Tooltip.
- Necesita una decisión antes de seguir, o tiene muchos campos: Dialog o Drawer.
Para todos
- Se abre al presionar, nunca al pasar el puntero. El botón dice si está abierto (
aria-expanded). - Es un diálogo con nombre (
label). El foco entra, Escape o presionar afuera lo cierran y el foco vuelve al botón. - Se dibuja en la capa superior y se da vuelta o se corre para quedar dentro de la ventana, también en celulares.
Props
| Popover | Tipo | Por defecto |
|---|---|---|
labelobligatorio | string | |
triggerobligatorio | ReactElement<any, string | JSXElementConstructor<any>> | |
placement | "bottom start" | "bottom end" | "top start" | "top end" | "bottom" | "top" | bottom start |