SplitPane
Two panes with a draggable divider. The grip swells while held, arrow keys nudge, Home and End jump to the limits, and a double click springs back. Layout.
Open playgroundEditor
Drag the grip, or focus it and use the arrow keys.
Preview
Double click the grip to reset.
About
SplitPane is a React component in the Layout category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { SplitPane } from "@ashutoshswamy/smoui" and set first, defaultSize, min among its 5 props.
Install
npm i @ashutoshswamy/smouiUsage
import { SplitPane } from "@ashutoshswamy/smoui";
<SplitPane
className="h-96"
defaultSize={0.4}
min={0.2}
max={0.8}
first={<Editor />}
second={<Preview />}
/>Props 5
- first / second
The two panes. Each scrolls on its own.
ReactNode- defaultSize
Share the first pane starts with, 0 to 1.
numberdefault0.5- min / max
Limits for the first pane's share.
numberdefault0.2 / 0.8- direction
Vertical splits need a real height on className.
"horizontal""vertical"default"horizontal"- label
Accessible name for the divider.
stringdefault"Resize panes"
More layout components
- AccordionStacked disclosures. The plus turns to a cross and the answer unfolds on a spring.
- BentoGridMixed-size tiles that rise in as a stagger, lift on hover, with a light that trails the cursor.
- CarouselDrag or flick: slides coast then snap to centre on a spring while the neighbours shrink and dim.
- EmptyStateWhat to show when there is nothing yet. Cards fan out behind an icon, the text rises in and hovering spreads the cards.
- MasonryTiles of different heights packed into the shortest column, every column ending on the same line. They rise in one after another and glide to their new place when the column count changes.
- ReorderListA list you reorder by its grip. Neighbours slide aside on a spring, and the keyboard works too: focus the grip, press arrow up or down. Moves are announced.