Skip to content

Layer

The floating level of the page: fixed to the window, above everything, outside the page's overflow. Dialog, Popover and Toast already live there.

import { Layer } from '@sypnia/ui/react'

On this page
  1. A bar above the page
  2. When to use it
  3. For everyone
  4. Props

A bar above the page

Code
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>}
    </>
  );
}

When to use it

Use it when

  • A floating thing of your own that is not a Dialog, Popover or Toast.

Do not use it when

  • Anything the library already floats.

For everyone

  • Moving something into the Layer does not move the focus: manage it with FocusScope when needed.

Props

LayerTypeDefault
className string
inset boolean
style CSSProperties
  1. A bar above the page
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms