suiss/ui ยท Pattern
Flyout
A non-modal panel anchored to a trigger on desktop that becomes a bottom drawer on mobile.
Flyout is an open-source pattern from suiss/ui for React. The @esuiss/ui CLI copies its source into your project, so you own the code.
Flyout shows supplementary content, such as a small form or a share link, next to the control that opened it. On desktop it renders a Popover positioned against the trigger. Below the 48rem breakpoint it renders a bottom Drawer with a swipe handle, and each part switches to its drawer counterpart.
Use it for quick settings or filters that do not need a full modal.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Usage
Composition
Use the following composition to build a Flyout:
Examples
With close button
Set showCloseButton to add an icon close button to the mobile drawer. It has no effect on desktop.
With close label
Set closeLabel together with showCloseButton to show a text close button labelled Done in the mobile drawer.
With close
Wrap a button in FlyoutClose so its action also closes the flyout, here a Copy link button. On desktop, use it when the popover needs an explicit close control.
Floating
Set floating to inset the mobile drawer from the screen edges with fully rounded corners.
Accessibility
- The popup has the
dialogrole, named byFlyoutTitleand described byFlyoutDescription. - Opening moves focus into the flyout.
Escapecloses it and returns focus to the trigger; pressing outside also closes it.
API Reference
Flyout
The root that renders a Popover on desktop and a Drawer on mobile.
| Prop | Type | Default |
|---|---|---|
open | boolean | - |
defaultOpen | boolean | - |
onOpenChange | (open: boolean) => void | - |
floating | boolean | - |
children | React.ReactNode | - |
The flyout is uncontrolled with defaultOpen, or controlled with open and onOpenChange.
FlyoutTrigger
The button that opens the flyout.
| Prop | Type | Default |
|---|---|---|
render | React.ReactElement | - |
| Prop | Type | Default |
|---|---|---|
asChild | boolean | - |
Also accepts the props of React.ButtonHTMLAttributes<HTMLButtonElement>.
Also accepts className, children, id and aria-label.
FlyoutContent
The popup; a PopoverContent on desktop and a DrawerContent on mobile.
| Prop | Type | Default |
|---|---|---|
showCloseButton | boolean | - |
closeLabel | string | - |
Also accepts align, alignOffset, side and sideOffset from PopoverContent, which position the desktop popover, and the props of React.HTMLAttributes<HTMLElement>.
Also accepts align, alignOffset, side and sideOffset from PopoverContent, which position the desktop popover, and className, style, children, id and aria-label.
The positioning props are ignored on mobile, and showCloseButton and closeLabel only affect the mobile drawer.
FlyoutHeader
Groups the title and description.
Also accepts the props of React.ComponentProps<"div">.
FlyoutTitle
The flyout's title, used as its accessible name.
Also accepts the props of React.HTMLAttributes<HTMLHeadingElement>.
Also accepts className, children and id.
FlyoutDescription
Supporting text, used as the flyout's accessible description.
Also accepts the props of React.HTMLAttributes<HTMLParagraphElement>.
Also accepts className, children and id.
FlyoutBody
The main content area, padded on mobile.
Also accepts the props of React.ComponentProps<"div">.
Put interactive content here.
FlyoutClose
A button that closes the flyout.
| Prop | Type | Default |
|---|---|---|
render | React.ReactElement | - |
| Prop | Type | Default |
|---|---|---|
asChild | boolean | - |
Also accepts the props of React.ButtonHTMLAttributes<HTMLButtonElement>.
Also accepts className, children, id and aria-label.
Use render on FlyoutTrigger and FlyoutClose to replace the default button with your own element, such as a Button.
Set asChild on FlyoutTrigger and FlyoutClose to render your own element, such as a Button, in place of the default button.
Each part sets a data-slot, such as flyout-content or flyout-close, for styling.