Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / Structure

SplitPane

Two panes with a divider people can move, by dragging it or with the keyboard.

Awindow splitter

When to useLink to "When to use"

  • List and detail, editor and preview, code and output: two regions whose balance depends on the task.

Use something else when:

  • the side region is navigation: AppShell
  • the second region is temporary: a Sheet

UsageLink to "Usage"

tsx
Copy
import { SplitPane } from "@arshad-shah/cynosure";

<div style={{ blockSize: "100%" }}>
  <SplitPane label="Resize the file list" start={<FileList />} end={<Preview />} defaultSize={30} />
</div>

The SplitPane fills its container, so give the container a size. Each pane scrolls on its own. Remember the size by passing size and onSizeChange, and save it in onResizeEnd.

Stacked and collapsibleLink to "Stacked and collapsible"

orientation="vertical" stacks the panes. With collapsible, Enter on the divider collapses the start pane and restores it.

anchor="end" gives the size to the end pane, so with unit="px" a right sidebar or a bottom dock keeps its pixels as the window grows and the start pane takes the rest. collapsed, defaultCollapsed and onCollapsedChange collapse the anchored pane from a menu or a button; its size is kept and comes back when it expands. onResizeEnd is called once, with the final size, when a drag is released or a resize key is let go: the moment to save the size.

tsx
Copy
<SplitPane
  label="Resize the results"
  orientation="vertical"
  unit="px"
  anchor="end"
  start={<Editor />}
  end={<Results />}
  defaultSize={240}
  onResizeEnd={saveHeight}
  collapsed={!resultsOpen}
  onCollapsedChange={(collapsed) => setResultsOpen(!collapsed)}
/>

PropsLink to "Props"

Every prop of SplitPane
PropWhat it doesTypeDefault
startRequired
The first pane (left, or right in right-to-left text; top when vertical).ReactNode
endRequired
The second pane (right, or left in right-to-left text; bottom when vertical).ReactNode
labelRequired
Accessible name of the divider, e.g. "Resize the file list".string
orientation
horizontal: panes side by side. vertical: stacked."horizontal" | "vertical"
unit
percent (default): sizes are percent of the whole. px: the sized pane (see anchor) has a fixed width (or height) in pixels, such as a sidebar that keeps its size as the window grows."percent" | "px"
anchor
Which pane the size, limits, collapse and divider value belong to. start (default): the first pane, such as a left sidebar. end: the second pane, such as a right sidebar or a bottom dock that keeps its pixels as the window grows."start" | "end"
size
Size of the sized pane (see anchor), in unit. Kept while it is collapsed, so expanding restores it.number
defaultSize
Starting size of the sized pane when uncontrolled, in unit. Default 50 percent, or 240 pixels.number50 percent
onSizeChange
Called with the new size as the divider moves, on every step of a drag or key.((size: number) => void)
onResizeEnd
Called once with the final size when a resize ends: the pointer is released, or the arrow (or Page, Home, End) key is let go. Not called when nothing changed or the drag was cancelled. Use it to save the size.((size: number) => void)
min
Smallest size of the sized pane, in unit. Default 10 percent, or 120 pixels.number10 percent
max
Largest size of the sized pane, in unit. Default 90 percent, or 600 pixels.number90 percent
step
Arrow keys move by this much, in unit. Default 5 percent, or 16 pixels.number5 percent
collapsible
Enter on the divider collapses the sized pane to 0 and restores it. Default true when collapsed or defaultCollapsed is given, false otherwise.booleantrue
collapsed
Whether the sized pane is collapsed, for a sidebar or dock toggled from a menu or button. Its size is kept.boolean
defaultCollapsed
Whether the sized pane starts collapsed when collapsed is not controlled.boolean
onCollapsedChange
Called when the divider collapses or expands the pane (Enter, or a key or drag that opens it).((collapsed: boolean) => void)
className
Added to the root element, for layout.string
style
Layout only. Restyle through --cy-split-pane-* tokens.CSSProperties

Generated from the type definitions in @arshad-shah/cynosure 0.5.0.

Behaviour and accessibilityLink to "Behaviour and accessibility"

  • Role: the divider is a focusable separator named by label, with the anchored pane's size (the start pane unless anchor="end"; 0 when collapsed) as aria-valuenow and aria-controls pointing at that pane.
  • Keyboard: the keys move the divider, so the anchored pane grows or shrinks with it.
Behaviour and accessibility, table 1
KeyAction
Arrow Left / RightMove the divider (side by side; flipped in right-to-left text)
Arrow Up / DownMove the divider (stacked)
Home / EndThe anchored pane to min / max
EnterCollapse or restore the anchored pane (with collapsible, collapsed or defaultCollapsed)

Collapsed, a key that grows the pane opens it at min; the others leave it closed. onResizeEnd fires when the key is let go.

  • Pointer and touch: drag the divider; it keeps focus afterwards so the keys can fine-tune. Dragging a collapsed divider opens the pane, and Escape puts back the size and collapse the drag began with. Its hit area is at least 24px wide, 44px on touch screens, and touch dragging does not scroll the page.
  • Direction: the start pane is on the right in right-to-left text.

ThemingLink to "Theming"

Tokens: --cy-split-pane-divider-size and --cy-split-pane-divider.

AppShell · Slider

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog