Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Floating Panel for React Radix UI

Displays content in a floating window.

Framework
UI library

Radix UI does not include this primitive, so this page uses the Ark UI component. The visuals match the Ark UI version.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/radix/floating-panel.json

Anatomy

FloatingPanelTrigger
FloatingPanelContent
└── FloatingPanelContent
FloatingPanelHeader
FloatingPanelBody
FloatingPanelTitle
FloatingPanelResizeTrigger
FloatingPanelDragTrigger
FloatingPanelStageTrigger
FloatingPanelCloseTrigger
FloatingPanelControl

Usage

import { createListCollection } from "@ark-ui/react/collection";
import { Settings2Icon, XIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Field, FieldLabel } from "@/components/ui/field";
import {
  FloatingPanel,
  FloatingPanelBody,
  FloatingPanelCloseTrigger,
  FloatingPanelContent,
  FloatingPanelControl,
  FloatingPanelFooter,
  FloatingPanelHeader,
  FloatingPanelMaximize,
  FloatingPanelMinimize,
  FloatingPanelRestore,
  FloatingPanelTitle,
  FloatingPanelTrigger,
} from "@/components/ui/floating-panel";
import {
  NumberInput,
  NumberInputDecrement,
  NumberInputGroup,
  NumberInputIncrement,
  NumberInputInput,
} from "@/components/ui/number-input";
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select";
const FloatingPanelDemo = () => (
  <FloatingPanel defaultSize={{ width: 360, height: 300 }}>
    <FloatingPanelTrigger asChild>
      <Button variant="outline">Open</Button>
    </FloatingPanelTrigger>
    <FloatingPanelContent>
      <FloatingPanelHeader>
        <Settings2Icon />
        <FloatingPanelTitle>Settings</FloatingPanelTitle>
        <FloatingPanelControl>
          <FloatingPanelMinimize />
          <FloatingPanelMaximize />
          <FloatingPanelRestore />
          <FloatingPanelCloseTrigger asChild>
            <Button aria-label="Close" size="icon-xs">
              <XIcon aria-hidden />
            </Button>
          </FloatingPanelCloseTrigger>
        </FloatingPanelControl>
      </FloatingPanelHeader>
      <FloatingPanelBody>
        <Field>
          <FieldLabel>Font family</FieldLabel>
          <Select collection={collection} defaultValue={["Inter"]}>
            <SelectTrigger className="w-full">
              <SelectValue />
            </SelectTrigger>
            <SelectContent>
              {collection.items.map((item) => (
                <SelectItem item={item} key={item}>
                  {item}
                </SelectItem>
              ))}
            </SelectContent>
          </Select>
        </Field>
        <Field>
          <FieldLabel>Font size</FieldLabel>
          <NumberInput className="w-full" defaultValue="16">
            <NumberInputGroup>
              <NumberInputDecrement />
              <NumberInputInput />
              <NumberInputIncrement />
            </NumberInputGroup>
          </NumberInput>
        </Field>
      </FloatingPanelBody>
      <FloatingPanelFooter>
        <Button variant="outline">Save</Button>
      </FloatingPanelFooter>
    </FloatingPanelContent>
  </FloatingPanel>
);

const collection = createListCollection({
  items: ["Inter", "Roboto", "Helvetica", "Geist"],
});

Accessibility

KeyDescription
Enter
Activate the focused control.
Space
Activate the focused control.
ArrowLeft
Move left.
ArrowRight
Move right.
ArrowUp
Move up.
ArrowDown
Move down.
Home
Go to the start.
End
Go to the end.

Demos

Controlled Position

Controlled Size

Custom Spacing

API Reference

FloatingPanel

PropType
children?ReactNode
AttributeType

FloatingPanelTrigger

button

PropType
AttributeType

FloatingPanelPositioner

div

PropType
AttributeType
CSS variableType
--heightstring
--widthstring
--xstring
--ystring
--z-indexstring

FloatingPanelContent

div

PropType
AttributeType
CSS variableType
--heightstring
--widthstring
--xstring
--ystring

FloatingPanelHeader

div

PropType
AttributeType
CSS variableType
--spacestring

FloatingPanelBody

div

PropType
AttributeType
CSS variableType
--spacestring

FloatingPanelTitle

h2

PropType
AttributeType

FloatingPanelResizeTrigger

div

PropType
AttributeType

FloatingPanelDragTrigger

div

PropType
AttributeType

FloatingPanelStageTrigger

button

PropType
AttributeType

FloatingPanelCloseTrigger

button

PropType
AttributeType

FloatingPanelControl

div

PropType
AttributeType

FloatingPanelMinimize

button

PropType
AttributeType

FloatingPanelMaximize

button

PropType
AttributeType

FloatingPanelRestore

button

PropType
className?string
AttributeType

FloatingPanelFooter

div

PropType
AttributeType
CSS variableType
--radius-2xlstring
--spacestring

useFloatingPanel

PropType