Back to Shadcn Ui

Resizable

apps/v4/content/docs/components/radix/resizable.mdx

latest2.9 KB
Original Source

<ComponentPreview styleName="radix-nova" name="resizable-demo" previewClassName="h-80" />

About

The Resizable component is built on top of react-resizable-panels by bvaughn.

Installation

<CodeTabs> <TabsList> <TabsTrigger value="cli">Command</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">
bash
npx shadcn@latest add resizable
</TabsContent> <TabsContent value="manual"> <Steps className="mb-0 pt-2">

<Step>Install the following dependencies:</Step>

bash
npm install react-resizable-panels

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="resizable" title="components/ui/resizable.tsx" styleName="radix-nova" />

<Step>Update the import paths to match your project setup.</Step>

</Steps> </TabsContent> </CodeTabs>

Usage

tsx
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/components/ui/resizable"
tsx
<ResizablePanelGroup orientation="horizontal">
  <ResizablePanel>One</ResizablePanel>
  <ResizableHandle />
  <ResizablePanel>Two</ResizablePanel>
</ResizablePanelGroup>

Examples

Vertical

Use orientation="vertical" for vertical resizing.

<ComponentPreview styleName="radix-nova" name="resizable-vertical" />

Handle

Use the withHandle prop on ResizableHandle to show a visible handle.

<ComponentPreview styleName="radix-nova" name="resizable-handle" />

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

<ComponentPreview styleName="radix-nova" name="resizable-rtl" direction="rtl" />

API Reference

See the react-resizable-panels documentation.

Changelog

2025-02-02 react-resizable-panels v4

Updated to react-resizable-panels v4. See the v4.0.0 release notes for full details.

If you're using react-resizable-panels primitives directly, note the following changes:

v3v4
PanelGroupGroup
PanelResizeHandleSeparator
direction proporientation prop
defaultSize={50}defaultSize="50%"
onLayoutonLayoutChange
ImperativePanelHandlePanelImperativeHandle
ref prop on PanelpanelRef prop
data-panel-group-directionaria-orientation
<Callout> The shadcn/ui wrapper components (`ResizablePanelGroup`, `ResizablePanel`, `ResizableHandle`) remain unchanged. </Callout>