Splitter / resizable
Two resizable panes with a draggable divider.
Example
File list
Preview
<div class="full"> <focsd-splitter label="Resize file list" value="40" style="block-size: 10rem"> <div slot="start">File list</div> <div slot="end">Preview</div> </focsd-splitter></div>Panes
Any number of resizable panes, side by side or stacked, with collapsible panes and a saved layout.
<div class="full"> <focsd-splitter autosave="docs-mail" style="block-size: 14rem"> <focsd-splitter-pane label="Folders" size="25" min="15" >Inbox, Sent, Drafts</focsd-splitter-pane > <focsd-splitter-pane label="Messages" min="20" >Quarterly report draft</focsd-splitter-pane > <focsd-splitter-pane label="Preview" size="35" collapsible >Select a message to read it here.</focsd-splitter-pane > </focsd-splitter></div>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/components/focsd-splitter.js';</script>
<focsd-splitter label="Resize file list" value="40">…</focsd-splitter>import { Splitter } from '@focsd-dev/react';
export function Example() { return <Splitter onChange={(e) => console.log(e.target)} label="Resize file list" value="40">…</Splitter>;}<script setup>import '@focsd-dev/components/focsd-splitter.js';</script>
<template> <focsd-splitter @change="onChange" label="Resize file list" value="40">…</focsd-splitter></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-splitter.js';
// template<focsd-splitter (change)="onChange($event)" label="Resize file list" value="40">…</focsd-splitter><script> import '@focsd-dev/components/focsd-splitter.js';</script>
<focsd-splitter onchange={(e) => console.log(e.target)} label="Resize file list" value="40">…</focsd-splitter>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
label | label | string | — |
value | value | number | 50 |
min | min | number | 10 |
max | max | number | 90 |
orientation | orientation | 'horizontal' | 'vertical' | horizontal |
autosave | autosave | string | — |
Events
| Event | Description |
|---|---|
change | Fired when the user commits a change to the value or state (two-slot markup only). |
Slots
| Slot | Description |
|---|---|
(default) | focsd-splitter-pane elements, one per pane. |
end | The second pane. |
start | The first pane (its size is value). |
CSS parts
Style the inside of the component with ::part(), for example focsd-splitter::part(end).
| Part | Description |
|---|---|
end | The end element. |
pane | The wrapper round each pane's slot (`display: contents`). |
panes | The row (or column) of panes and separators. |
separator | The separator element. |
start | The start element. |
Accessibility
- APG window splitter: the divider is a focusable
role="separator"witharia-valuenow/min/maxandaria-controlspointing at the start pane.
Keyboard
| Key | Action |
|---|---|
| Arrow keys | Resize by 1% (10% with Shift) |
| Home / End | Minimum / maximum |
| Enter | Collapse or restore |
Panes
- Each boundary is an APG window splitter: a focusable
role="separator"named "Resize <pane label>", witharia-valuenow(the size of the pane before it) and that pane’sminandmaxasaria-valueminandaria-valuemax. - Separators are vertical lines in a row of panes and horizontal lines with
orientation="vertical";aria-orientationsays which. - A collapsed pane is hidden (
display: none), so its content leaves the tab order until it is restored. - The visible line is thin, but the pointer target is 24 px wide.
- With
autosave, the sizes are kept inlocalStorageunderfocsd-splitter:<key>and come back on the next visit. Splitters can be nested. - Markup with
startandendslots instead of panes keeps the two-pane behavior (changeevent). orientationis new and applies to panes only. It does not reflect, so style onfocsd-splitter[orientation=vertical]only when you set the attribute, not the property.
Keyboard
| Key | Action |
|---|---|
| Arrow keys | Resize by 1% (Left and Right in a row, mirrored right to left; Up and Down in a column) |
| Shift + arrow keys | Resize by 10% |
| Home / End | The pane before the separator to its minimum / maximum |
| Enter | Collapse or restore the collapsible pane beside the separator |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.