apps/design-system/content/docs/components/resizable.mdx
The Resizable component is built on top of react-resizable-panels by bvaughn.
npx shadcn-ui@latest add resizable
<Step>Install the following dependencies:</Step>
npm install react-resizable-panels
<Step>Copy and paste the following code into your project.</Step>
<ComponentSource name="resizable" /><Step>Update the import paths to match your project setup.</Step>
</Steps> </TabsContent> </Tabs>import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable'
<ResizablePanelGroup direction="horizontal">
<ResizablePanel>One</ResizablePanel>
<ResizableHandle />
<ResizablePanel>Two</ResizablePanel>
</ResizablePanelGroup>
Use the direction prop to set the direction of the resizable panels.
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable'
export default function Example() {
return (
<ResizablePanelGroup direction="vertical">
<ResizablePanel>One</ResizablePanel>
<ResizableHandle />
<ResizablePanel>Two</ResizablePanel>
</ResizablePanelGroup>
)
}
You can set or hide the handle by using the withHandle prop on the ResizableHandle component.
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable'
export default function Example() {
return (
<ResizablePanelGroup direction="horizontal">
<ResizablePanel>One</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel>Two</ResizablePanel>
</ResizablePanelGroup>
)
}