Portal
Dibuja su contenido al final de <body>, fuera de la caja donde está escrito y de su desborde.
import { Portal } from '@sypnia/ui/react'
En esta página
Fuera de un desborde
Código
import { Portal } from '@sypnia/ui/react';
// The box is drawn at the end of <body>, outside this example's frame (look at the bottom-right corner of the window).
export default function Out() {
return (
<div style={{ overflow: 'hidden', height: '3rem', border: '1px dashed var(--line-strong)', borderRadius: 'var(--r-2)', padding: 'var(--s-2)' }}>
A box with overflow hidden.
<Portal><div style={{ position: 'fixed', right: '1rem', bottom: '1rem', padding: 'var(--s-2) var(--s-3)', background: 'var(--bg-raised)', border: '1px solid var(--line)', borderRadius: 'var(--r-2)', zIndex: 'var(--z-toast)' as unknown as number }}>From a Portal</div></Portal>
</div>
);
} Cuándo usarlo
Úsalo cuando
- Construir una pieza flotante propia.
No lo uses cuando
- Contenido normal: sale del orden de lectura.
Para todos
- Su contenido cambia de lugar en el orden de la página: maneja tú el foco y los nombres.
Props
| Portal | Tipo | Por defecto |
|---|---|---|
container | Element | null |