Skip to content
shadcn.io
shadcn.io is not affiliated with official shadcn/ui

Shadcn Floating Panel for React and Tailwind

Displays content in a floating window.

Installation

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

Anatomy

FloatingPanel
├── FloatingPanelTrigger
└── FloatingPanelContent
    ├── FloatingPanelDragTrigger
    ├── FloatingPanelHeader
    │   ├── FloatingPanelControl
    │   │   ├── FloatingPanelMinimize
    │   │   ├── FloatingPanelMaximize
    │   │   └── FloatingPanelRestore
    │   ├── FloatingPanelTitle
    │   ├── FloatingPanelResizeTrigger
    │   ├── FloatingPanelStageTrigger
    │   └── FloatingPanelCloseTrigger
    ├── FloatingPanelBody
    └── FloatingPanelFooter

Usage

import { 
  FloatingPanel,
  FloatingPanelTrigger,
  FloatingPanelContent,
  FloatingPanelHeader,
  FloatingPanelTitle,
  FloatingPanelBody,
} from "@/components/ui/floating-panel";
<FloatingPanel>
  <FloatingPanelTrigger />
  <FloatingPanelContent>
    <FloatingPanelHeader>
      <FloatingPanelTitle />
    </FloatingPanelHeader>
    <FloatingPanelBody />
  </FloatingPanelContent>
</FloatingPanel>

Examples

Controlled Size

Control the panel size programmatically using the size and onSizeChange props.

Controlled Position

Control the panel position programmatically using the position and onPositionChange props.

Custom spacing

Use [--space:--spacing("value")] on FloatingPanelContent to adjust internal padding.

Default spacing is --spacing(4).

You can use breakpoint utilities to change the internal spacing at different screen sizes.

  md:[--space:--spacing(6)] lg:[--space:--spacing(8)]

API Reference

FloatingPanel

Root component. Manages panel position and drag state.

PropTypeDefault
openboolean-
defaultOpenbooleanfalse
onOpenChange(details: OpenChangeDetails) => void-
positionPoint-
defaultPositionPoint-
onPositionChange(details: PositionChangeDetails) => void-
sizeSize-
defaultSizeSize-
onSizeChange(details: SizeChangeDetails) => void-
lazyMountbooleantrue
unmountOnExitbooleantrue
closeOnEscapebooleantrue
draggablebooleantrue
resizablebooleantrue
classNamestring-

FloatingPanelTrigger

Opens the floating panel on click.

PropTypeDefault
classNamestring-
asChildbooleanfalse

FloatingPanelContent

Holds the panel content.

PropTypeDefault
resizablebooleantrue
classNamestring-
AttributeDefault
--space--spacing(4)

FloatingPanelHeader

Header area. Acts as drag handle for repositioning.

PropTypeDefault
classNamestring-

FloatingPanelTitle

Title for the panel.

PropTypeDefault
classNamestring-
asChildbooleanfalse

FloatingPanelBody

Scrollable body content. Uses ScrollArea for overflow.

PropTypeDefault
scrollFadebooleanfalse
classNamestring-

FloatingPanelCloseTrigger

Closes the panel on click.

PropTypeDefault
classNamestring-
asChildbooleanfalse

For a complete list of props, see the Ark UI documentation.