Portal
Draws its content at the end of <body>, out of the box it is written in and its overflow.
import { Portal } from '@sypnia/ui/react'
Out of an overflow
Code
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>
);
} When to use it
Use it when
- Building a floating piece of your own.
Do not use it when
- Regular content: it leaves the reading order.
For everyone
- Its content moves in the page's order: manage focus and naming yourself.
Props
| Portal | Type | Default |
|---|---|---|
container | Element | null |