Components

Overlay

Displays a viewport backdrop for overlay content.

tsx
import Overlay from '@precursor/overlay';

Example

tsx
'use client';

import { useState } from 'react';
import Overlay from '@precursor/overlay';
import Button from '@precursor/button';

export default function Example() {
    const [open, setOpen] = useState(false);

    return (
        <>
            <Button onClick={() => setOpen(true)}>Show backdrop</Button>
            {open && (
                <Overlay>
                    <Button onClick={() => setOpen(false)}>
                        Dismiss backdrop
                    </Button>
                </Overlay>
            )}
        </>
    );
}

Props

Overlay props
PropTypeDefaultNotes
onKeyDownKeyboardEventHandler——
onClickMouseEventHandler——
childrenRequiredReactNode——
refRef<HTMLDivElement>—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
keyKey | null——