Skip to content

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'

On this page
  1. Out of an overflow
  2. When to use it
  3. For everyone
  4. Props

Out of an overflow

A box with overflow hidden.
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

PortalTypeDefault
container Element | null
  1. Out of an overflow
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms