mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-22 12:15:43 +00:00
* feat(v4): update home page * fix * fix: cards * feat(v4): charts page * feat: update pages * feat: colors * fix * feat: add docs * feat: mdx work * fix * fix * fix: sidebar * fix: lint * feat: updates * feat: update components * feat: fix docs * fix: responsive * feat: implement cmdk * fix: update navigation menu demo * fix: code style * fix: themes * feat: implement blocks page * fix: docs config * refactor * fix: outputFileTracingIncludes * fix * fix: output * fix * fix: registry * refactor: move docs * debug: docs * debug * revert * fix: mjs * deps: pin fumadocs * debug * fix: downgrade next * fix: index page * refactor: move mdx components * fix: remove copy button * fix * was it zod * yes it was * remove copy page * fix: color page * fix: colors page * fix: meta colors * fix: copy button * feat: sync registry * fix: registry build script * feat: update port * feat: clean up examples * fix * fix: mobile nav * fix: blur for mobile * fix: sidebar nav * feat: update examples * fix: build scripts * feat: update components * feat: restyle * fix: types * fix: styles * fix: margins * fix: screenshots * fix * feat: update theme * fix: charts nav * fix: image * feat: optimize images * fix: menu * fix: card * fix: border * check * feat: implement charts page * fix: charts * fix: og images * feat: extend touch * fix: static * fix: sizing * fix: mobile screenshots * fix: page nav * fix * feat: update favicon * fix: theme selector * fix: feedback * fix: sink * docs: update * fix: styles * chore: update registry * fix: command * fix * fix: minor updates * fix: typography on smaller devices * fix: format * fix: remove unused icon * feat: update favicon * fix: typography * docs: typography page * fix: steps
130 lines
2.7 KiB
Plaintext
130 lines
2.7 KiB
Plaintext
---
|
|
title: Resizable
|
|
description: Accessible resizable panel groups and layouts with keyboard support.
|
|
component: true
|
|
links:
|
|
doc: https://github.com/bvaughn/react-resizable-panels
|
|
api: https://github.com/bvaughn/react-resizable-panels/tree/main/packages/react-resizable-panels
|
|
---
|
|
|
|
<ComponentPreview
|
|
name="resizable-demo"
|
|
description="A group of resizable horizontal and vertical panels."
|
|
/>
|
|
|
|
## About
|
|
|
|
The `Resizable` component is built on top of [react-resizable-panels](https://github.com/bvaughn/react-resizable-panels) by [bvaughn](https://github.com/bvaughn).
|
|
|
|
## Installation
|
|
|
|
<CodeTabs>
|
|
|
|
<TabsList>
|
|
<TabsTrigger value="cli">CLI</TabsTrigger>
|
|
<TabsTrigger value="manual">Manual</TabsTrigger>
|
|
</TabsList>
|
|
<TabsContent value="cli">
|
|
|
|
```bash
|
|
npx shadcn@latest add resizable
|
|
```
|
|
|
|
</TabsContent>
|
|
|
|
<TabsContent value="manual">
|
|
|
|
<Steps>
|
|
|
|
<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" />
|
|
|
|
<Step>Update the import paths to match your project setup.</Step>
|
|
|
|
</Steps>
|
|
|
|
</TabsContent>
|
|
|
|
</CodeTabs>
|
|
|
|
## Usage
|
|
|
|
```tsx showLineNumbers
|
|
import {
|
|
ResizableHandle,
|
|
ResizablePanel,
|
|
ResizablePanelGroup,
|
|
} from "@/components/ui/resizable"
|
|
```
|
|
|
|
```tsx showLineNumbers
|
|
<ResizablePanelGroup direction="horizontal">
|
|
<ResizablePanel>One</ResizablePanel>
|
|
<ResizableHandle />
|
|
<ResizablePanel>Two</ResizablePanel>
|
|
</ResizablePanelGroup>
|
|
```
|
|
|
|
## Examples
|
|
|
|
### Vertical
|
|
|
|
Use the `direction` prop to set the direction of the resizable panels.
|
|
|
|
<ComponentPreview
|
|
name="resizable-vertical"
|
|
description="A group of resizable vertical panels."
|
|
/>
|
|
|
|
```tsx showLineNumbers {9}
|
|
import {
|
|
ResizableHandle,
|
|
ResizablePanel,
|
|
ResizablePanelGroup,
|
|
} from "@/components/ui/resizable"
|
|
|
|
export default function Example() {
|
|
return (
|
|
<ResizablePanelGroup direction="vertical">
|
|
<ResizablePanel>One</ResizablePanel>
|
|
<ResizableHandle />
|
|
<ResizablePanel>Two</ResizablePanel>
|
|
</ResizablePanelGroup>
|
|
)
|
|
}
|
|
```
|
|
|
|
### Handle
|
|
|
|
You can set or hide the handle by using the `withHandle` prop on the `ResizableHandle` component.
|
|
|
|
<ComponentPreview
|
|
name="resizable-handle"
|
|
description="A group of resizable panels with a handle."
|
|
/>
|
|
|
|
```tsx showLineNumbers {11}
|
|
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>
|
|
)
|
|
}
|
|
```
|