Skip to Content
Documentation
Getting startedComponentsChartsTheming
Get Pro
Overview
Concepts

Splitter

Used to create resizable panels that the user can drag apart with a handle

Recipe
A
B

Anatomy

import { Splitter } from '@chakra-ui/react'
<Splitter.Root>
  <Splitter.Panel />
  <Splitter.ResizeTrigger>
    <Splitter.ResizeTriggerSeparator />
    <Splitter.ResizeTriggerIndicator />
  </Splitter.ResizeTrigger>
  <Splitter.Panel />
</Splitter.Root>

The Splitter.ResizeTrigger renders the Splitter.ResizeTriggerSeparator and Splitter.ResizeTriggerIndicator for you, so writing <Splitter.ResizeTrigger id="a:b" /> is enough unless you need to customize the separator or indicator.

Examples

Controlled

Use the size and onResize props to manage panel sizes programmatically.

<Splitter.Root
  panels={[{ id: 'a' }, { id: 'b' }]}
  size={sizes}
  onResize={(details) => setSizes(details.size)}
>
  {/* ... */}
</Splitter.Root>
Drag the handle to resize panels
A
B
Panel A: 50.0% | Panel B: 50.0%

Vertical

Pass the orientation="vertical" prop to the Splitter.Root component for stacked panels that resize vertically.

A
B

Multiple Panels

Create layouts with more than two resizable panels by passing an array of panels to the panels prop of the Splitter.Root component.

A
B
C

Collapsible Panels

Make the panels collapsible and snapped to a specific size by setting the collapsible and collapsedSize properties on a panel in the panels array.

<Splitter.Root
  defaultSize={[40, 60]}
  panels={[
    { id: 'a', collapsible: true, collapsedSize: 5, minSize: 25 },
    { id: 'b', minSize: 50 },
  ]}
>
  {/* ... */}
</Splitter.Root>
Drag the resizer to collapse or expand Panel A
A
B

Min/Max Constraints

Set minSize and maxSize on panels to constrain their resizable range and prevent resizing beyond these boundaries.

Drag to resize - Panel A: 20-60%, Panel B: min 40%
A
30.0% (min: 20%, max: 60%)
B
70.0% (min: 40%)

Nested Panels

Nest splitters inside panels to create more complex layouts. Each nested splitter can have its own orientation, sizes, and behaviors independent of the parent splitter.

A
B1
B2

Storage

Set a defaultSize and pair it with a storage solution, such as useLocalStorage, to save users' panel size preferences. This ensures that panel layouts persist across sessions. Alternatively, you can use cookies or other storage mechanisms depending on your needs.

Drag to resize panels
A
B
LocalStorage [70.0, 50.0]

Props

Root

PropDefaultType
panels *
PanelData[]

The size constraints of the panels.

orientation '\'horizontal\''
'horizontal' | 'vertical'

The orientation of the splitter. Can be `horizontal` or `vertical`

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
defaultSize
PanelSize[]

The initial size of the panels when rendered. Use when you don't need to control the size of the panels.

id
string

The unique identifier of the machine.

ids
Partial<{ root: string resizeTrigger: (id: string) => string label: (id: string) => string panel: (id: string | number) => string }>

The ids of the elements in the splitter. Useful for composition.

keyboardResizeBy
number

The number of pixels to resize the panel by when the keyboard is used.

nonce
string

The nonce for the injected splitter cursor stylesheet.

onCollapse
(details: ExpandCollapseDetails) => void

Function called when a panel is collapsed.

onExpand
(details: ExpandCollapseDetails) => void

Function called when a panel is expanded.

onResize
(details: ResizeDetails) => void

Function called when the splitter is resized.

onResizeEnd
(details: ResizeEndDetails) => void

Function called when the splitter resize ends.

onResizeStart
() => void

Function called when the splitter resize starts.

registry
SplitterRegistry

The splitter registry to use for multi-drag support. When provided, enables dragging at the intersection of multiple splitters.

size
PanelSize[]

The controlled size data of the panels

Panel

PropDefaultType
id *
string

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

ResizeTrigger

PropDefaultType
id *
ResizeTriggerId

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
disabled
boolean