suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Patterns19
  • Overview
  • Action Bar
  • Action Menu
  • App Shell
  • Command Palette
  • Confirm
  • Context Actions
  • Date Picker
  • Flyout
  • Modal
  • Navbar
  • Paged List
  • Panel
  • Picker
  • Preview
  • Search Picker
  • Segment Picker
  • Split View
  • Table List
  • Trail

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.

import {
  Flyout,
  FlyoutBody,
  FlyoutContent,
  FlyoutDescription,
  FlyoutHeader,
  FlyoutTitle,
  FlyoutTrigger,
} from "@/components/patterns/flyout"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

export default function FlyoutDemo() {
  return (
    <div className="flex min-h-svh items-center justify-center">

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

$ pnpm dlx shadcn@latest add @esuiss/flyout

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add patterns flyout
  1. Install the following dependencies and add the cn helper:
$ pnpm add @base-ui/react
  1. Add the pieces it builds on: Drawer, Popover, use-mobile.

  2. Copy and paste the following code into your project.

components/patterns/flyout.tsx
"use client"

import { Popover as PopoverPrimitive } from "@base-ui/react/popover"
import * as React from "react"
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"
import {
  Popover,
  PopoverContent,
  1. Update the import paths to match your project setup.

Usage

import {
  Flyout,
  FlyoutBody,
  FlyoutClose,
  FlyoutContent,
  FlyoutDescription,
  FlyoutHeader,
  FlyoutTitle,
  FlyoutTrigger,
} from "@/components/patterns/flyout"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
<div className="flex min-h-svh items-center justify-center">
  <Flyout>
    <FlyoutTrigger render={<Button variant="outline" />}>
      Dimensions
    </FlyoutTrigger>
    <FlyoutContent>
      <FlyoutHeader>
        <FlyoutTitle>Dimensions</FlyoutTitle>
        <FlyoutDescription>
          Set the dimensions for the layer.
        </FlyoutDescription>
      </FlyoutHeader>
      <FlyoutBody className="grid gap-3">
        <div className="grid grid-cols-3 items-center gap-3">
          <Label htmlFor="flyout-width">Width</Label>
          <Input
            id="flyout-width"
            defaultValue="100%"
            className="col-span-2"
          />
        </div>
        <div className="grid grid-cols-3 items-center gap-3">
          <Label htmlFor="flyout-height">Height</Label>
          <Input
            id="flyout-height"
            defaultValue="25px"
            className="col-span-2"
          />
        </div>
      </FlyoutBody>
    </FlyoutContent>
  </Flyout>
</div>
<div className="flex min-h-svh items-center justify-center">
  <Flyout>
    <FlyoutTrigger asChild>
      <Button variant="outline">Dimensions</Button>
    </FlyoutTrigger>
    <FlyoutContent>
      <FlyoutHeader>
        <FlyoutTitle>Dimensions</FlyoutTitle>
        <FlyoutDescription>
          Set the dimensions for the layer.
        </FlyoutDescription>
      </FlyoutHeader>
      <FlyoutBody className="grid gap-3">
        <div className="grid grid-cols-3 items-center gap-3">
          <Label htmlFor="flyout-width">Width</Label>
          <Input
            id="flyout-width"
            defaultValue="100%"
            className="col-span-2"
          />
        </div>
        <div className="grid grid-cols-3 items-center gap-3">
          <Label htmlFor="flyout-height">Height</Label>
          <Input
            id="flyout-height"
            defaultValue="25px"
            className="col-span-2"
          />
        </div>
      </FlyoutBody>
    </FlyoutContent>
  </Flyout>
</div>

Composition

Use the following composition to build a Flyout:

Flyout
โ”œโ”€โ”€ FlyoutTrigger
โ””โ”€โ”€ FlyoutContent
    โ”œโ”€โ”€ FlyoutHeader
    โ”‚   โ”œโ”€โ”€ FlyoutTitle
    โ”‚   โ””โ”€โ”€ FlyoutDescription
    โ””โ”€โ”€ FlyoutBody
        โ””โ”€โ”€ FlyoutClose

Examples

With close button

Set showCloseButton to add an icon close button to the mobile drawer. It has no effect on desktop.

import {
  Flyout,
  FlyoutBody,
  FlyoutContent,
  FlyoutDescription,
  FlyoutHeader,
  FlyoutTitle,
  FlyoutTrigger,
} from "@/components/patterns/flyout"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

export default function FlyoutWithCloseButton() {
  return (
    <div className="flex min-h-svh items-center justify-center">

With close label

Set closeLabel together with showCloseButton to show a text close button labelled Done in the mobile drawer.

import {
  Flyout,
  FlyoutBody,
  FlyoutContent,
  FlyoutDescription,
  FlyoutHeader,
  FlyoutTitle,
  FlyoutTrigger,
} from "@/components/patterns/flyout"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

export default function FlyoutWithCloseLabel() {
  return (
    <div className="flex min-h-svh items-center justify-center">

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.

import {
  Flyout,
  FlyoutBody,
  FlyoutClose,
  FlyoutContent,
  FlyoutDescription,
  FlyoutHeader,
  FlyoutTitle,
  FlyoutTrigger,
} from "@/components/patterns/flyout"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"

export default function FlyoutWithClose() {
  return (
    <div className="flex min-h-svh items-center justify-center">

Floating

Set floating to inset the mobile drawer from the screen edges with fully rounded corners.

import {
  Flyout,
  FlyoutBody,
  FlyoutContent,
  FlyoutDescription,
  FlyoutHeader,
  FlyoutTitle,
  FlyoutTrigger,
} from "@/components/patterns/flyout"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

export default function FlyoutFloating() {
  return (
    <div className="flex min-h-svh items-center justify-center">

Accessibility

  • The popup has the dialog role, named by FlyoutTitle and described by FlyoutDescription.
  • Opening moves focus into the flyout.
  • Escape closes 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.

PropTypeDefault
openboolean-
defaultOpenboolean-
onOpenChange(open: boolean) => void-
floatingboolean-
childrenReact.ReactNode-

The flyout is uncontrolled with defaultOpen, or controlled with open and onOpenChange.

FlyoutTrigger

The button that opens the flyout.

PropTypeDefault
renderReact.ReactElement-
PropTypeDefault
asChildboolean-

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.

PropTypeDefault
showCloseButtonboolean-
closeLabelstring-

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.

PropTypeDefault
renderReact.ReactElement-
PropTypeDefault
asChildboolean-

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.

NextModalPreviousDate Picker

On this page

  1. 01Installation
  2. 02Usage
  3. 03Composition
  4. 04Examples
    • With close button
    • With close label
    • With close
    • Floating
  5. 05Accessibility
  6. 06API Reference
    • Flyout
    • FlyoutTrigger
    • FlyoutContent
    • FlyoutHeader
    • FlyoutTitle
    • FlyoutDescription
    • FlyoutBody
    • FlyoutClose