Resizable
Accessible resizable panel groups and layouts with keyboard support.
Preview
Installation
npx sigma-ui@latest add resizableUsage
<script setup lang="ts">
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from '@/components/ui/resizable';
</script>
<template>
<ResizablePanelGroup direction="horizontal">
<ResizablePanel>One</ResizablePanel>
<ResizableHandle />
<ResizablePanel>Two</ResizablePanel>
</ResizablePanelGroup>
</template>defaultSize,minSize, andmaxSizeonResizablePanelare percentages of the group.- Set
auto-save-idonResizablePanelGroupto persist the layout in local storage.
Examples
Vertical
Use the direction prop to set the direction of the resizable panels.
<script setup lang="ts">
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from '@/components/ui/resizable';
</script>
<template>
<ResizablePanelGroup direction="vertical">
<ResizablePanel>One</ResizablePanel>
<ResizableHandle />
<ResizablePanel>Two</ResizablePanel>
</ResizablePanelGroup>
</template>Handle
You can set or hide the handle by using the withHandle prop on the ResizableHandle component.
<script setup lang="ts">
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from '@/components/ui/resizable';
</script>
<template>
<ResizablePanelGroup direction="horizontal">
<ResizablePanel>One</ResizablePanel>
<ResizableHandle with-handle />
<ResizablePanel>Two</ResizablePanel>
</ResizablePanelGroup>
</template>API Reference
ResizablePanelGroup
Props
| Prop | Type | Default |
|---|---|---|
idGroup id; falls back to | string | null | - |
autoSaveIdUnique id used to auto-save group arrangement via | string | null | - |
directionrequiredThe group orientation of splitter. | Direction$1 | - |
keyboardResizeByStep size when arrow key was pressed. | number | null | - |
storageCustom storage API; defaults to localStorage | PanelGroupStorage | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Events
| Event | Payload |
|---|---|
layoutEvent handler called when group layout changes | [val: number[]] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
ResizableHandle
Props
| Prop | Type | Default |
|---|---|---|
idResize handle id (unique within group); falls back to | string | - |
hitAreaMarginsAllow this much margin when determining resizable handle hit detection | PointerHitAreaMargins | - |
tabindexTabindex for the handle | number | - |
disabledDisable drag handle | boolean | - |
nonceWill add | string | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
withHandleShows a visible grip icon on the handle. | boolean | - |
Events
| Event | Payload |
|---|---|
draggingEvent handler called when dragging the handler. | [isDragging: boolean] |
Accessibility
Adheres to the Window Splitter WAI-ARIA design pattern. Reka UI handles the roles, ARIA attributes, and keyboard interactions of the handle.
| Key | Description |
|---|---|
| Tab | Moves focus to the next handle or focusable element. |
| Enter | If the primary panel is not collapsed, collapses it. If it is collapsed, restores the handle to its previous position. |
| ArrowDown | Moves a horizontal handle down. |
| ArrowUp | Moves a horizontal handle up. |
| ArrowRight | Moves a vertical handle to the right. |
| ArrowLeft | Moves a vertical handle to the left. |
| Home | Moves the handle to give the primary panel its smallest allowed size. |
| End | Moves the handle to give the primary panel its largest allowed size. |