The primitive contract
The rules every part follows, from render instead of asChild to className and style as functions of the state, a merged ref, forwarded props and no text.
Splitter.Group, Splitter.Panel and Splitter.Separator follow the same rules, shared with
every Fragiola library. The package's tests enforce each one.
render, never asChild
A part renders a div by default. render replaces the element: an element, whose props are
merged with the part's, or a function of the props and the state, which must spread the props
(they carry the ref, the ARIA, the data-*, the handlers and the structural style).
<Splitter.Panel id="preview" render={<section aria-label="Preview" />} />
<Splitter.Panel
id="preview"
render={(props, state) => <section {...props} aria-label="Preview" aria-hidden={state.collapsed || undefined} />}
/>props.ref is a callback ref, so it fits any element: render={(props) => <hr {...props} />}
needs no cast.
className and style: a value or a function
Both take a value, or a function of the part's state:
<Splitter.Separator
aria-label="Resize"
className={(state) => (state.dragging ? "separator separator-active" : "separator")}
style={(state) => ({ opacity: state.disabled ? 0.4 : 1 })}
/>The state is GroupPartState, PanelPartState or SeparatorPartState (listed on each API
page). For styles that only follow state, prefer the data-* attributes from a stylesheet: the
same CSS then works for every framework's adapter.
Inline style is structural only
The package writes the flex sizing (and overflow: hidden on panels, touch-action: none on
separators), and nothing cosmetic: no colour, no cursor, no size for a separator. Your style is
merged under it, so a structural key always keeps the package's value. See
Geometry and units.
ref is a plain prop
ref is merged with the part's own callback ref (which binds the element to the engine), so
yours receives the element too:
const panelRef = useRef<HTMLElement>(null);
<Splitter.Panel id="chart" ref={panelRef} />;Props are forwarded, handlers composed
Every prop a part does not know goes to its element: aria-*, data-*, title, lang, event
handlers. (A group's and a panel's id is their model id; a panel's element takes it as its DOM
id.) A handler you pass runs after the part's own, so the part's behaviour
comes first and yours still sees the event.
A separator's pointer, key and double-click handling runs before the handlers you give the
separator itself, whichever was attached first: your handler sees event.defaultPrevented once
the separator has used the key. An event from content inside the separator (a button) reaches
the separator only as it bubbles, after that content's own listeners, so the content can keep a
press from starting a drag, moving the separator or resetting it: stop the event there
(stopPropagation()) or prevent it (preventDefault()). In Vue and Angular the content's
ordinary listeners do it (@pointerdown.stop, (pointerdown)="$event.stopPropagation()"). React
runs its handlers at the root, after the separator's: use the content's capture handlers
(onPointerDownCapture, onKeyDownCapture, onDoubleClickCapture).
State through data-* and ARIA only
A part never adds a class name. Its state is data-* (present or absent, never "false") and
ARIA. See State attributes.
No text, no names
The parts render only your children and set no aria-label. Every name comes from you: see
Accessible names.
Composition
Assemble groups, panels and separators under one namespace, nest groups in panels, swap any element with render, and drop to the hooks to build your own part.
State attributes
Every data-* attribute and ARIA value each part carries, what sets it, and how to style from it in CSS or Tailwind without a className function.