Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

data-splitter

Add a resizable drag divider between panels with keyboard support. The lightweight attribute alternative to the full split-surface web component.

Overview

The data-splitter attribute adds a resizable drag divider between two panels. It supports horizontal and vertical orientations, keyboard navigation, and min/max constraints. This is the lightweight attribute alternative to the full <split-surface> web component.

For persistence, collapse, and triple-pane layouts, see the split-surface component page.

Pairs naturally with the sidebar layout: the splitter switches it to no-wrap and drops the content column's minimum width so any content child (a main, a section data-layout="stack", a nested layout) can shrink beside the divider.

How It Works

Add data-splitter to a flex container with two child elements. The script needs at least two children and enhances only the first two; any further children are left alone and keep their normal flex sizing beside the second panel. The init script:

  1. Injects a div.split-divider between the two children
  2. Sets role="separator" on the divider with full ARIA attributes
  3. Listens for mouse drag, touch drag, and keyboard events on the divider
  4. Calculates the split position as a percentage and applies it to the first panel's flex-basis
  5. Reads data-min and data-max from the first child for constraints
  6. Clamps the initial 50% position into the data-min / data-max range
  7. Sets data-splitter-init (styling hook); removing and re-inserting the container never adds a second divider

The container must be a flex container. The script sizes the first panel with flex-basis and never sets display itself, so a bare <section data-splitter>, or a grid layout such as data-layout="split" or data-layout="grid", renders unchanged. Use data-layout="sidebar" (or <layout-sidebar>) or data-layout="cluster" for side-by-side panels. For data-splitter="vertical" the splitter sets flex-direction: column itself, so any flex container works; data-layout="stack" is the usual choice.

Attributes

Attribute Element Description
data-splitter Container Enables the splitter. Empty string for side-by-side panels, "vertical" for stacked panels.
data-label-resize Container Accessible name of the divider (default: "Resize panels"). Translate it for non-English pages.
data-min First child Minimum size of the first panel as a percentage (default: 10). 0 and non-numeric values fall back to the default.
data-max First child Maximum size of the first panel as a percentage (default: 90). 0 and non-numeric values fall back to the default.
data-splitter-init Container Set automatically once enhanced. Do not set manually.

Vertical Orientation

Set data-splitter="vertical" for a top/bottom split. The container needs a fixed height since vertical splits rely on the container's height to calculate proportions.

Min/Max Constraints

Add data-min and data-max to the first child element to constrain the drag range. Values are percentages. The divider stops at these boundaries during drag and keyboard navigation.

Injected Divider

The divider is a div.split-divider injected between the two child panels with the following accessibility attributes:

  • role="separator" and tabindex="0" for keyboard focus
  • aria-orientation naming the divider's own axis: vertical for side-by-side panels (a vertical bar), horizontal for stacked panels
  • aria-valuenow, aria-valuemin, aria-valuemax tracking the first panel's size
  • aria-controls pointing at the first panel (an id is generated if it has none)
  • aria-label from data-label-resize (default "Resize panels")

Keyboard Navigation

When the divider has focus, the following keyboard controls are available:

Key Action
ArrowLeft / ArrowRight Move divider by 1% in the arrow's direction (side-by-side). Mirrored in RTL, where the first panel is on the right.
ArrowUp / ArrowDown Move divider by 1% (stacked)
Shift + Arrow Move divider by 10%
Home / End Move to minimum / maximum position

Events

Event Detail Description
splitter:resize { position } Fired on the container during drag and keyboard resize (not on init); it bubbles. position is the first panel's size as a percentage. The position is not persisted — use <split-surface> for that.

Nested Splitters

Splitters can be nested for IDE-style layouts. Combine a horizontal sidebar split with a vertical editor/terminal split.

Styling

The divider is an injected div.split-divider; a ::after pseudo-element draws the grip. The rules live in src/web-components/split-surface/styles.css and are shared with <split-surface>. Layout fixes are gated on [data-splitter-init], so without JavaScript the panels stay in normal flow.

PartDefaultOverride with
Divider thickness5px (inline size for side-by-side panels, block size for vertical).split-divider { inline-size: … }
Divider colour--color-borderthe token, or background on .split-divider
Hover / dragging--color-interactivethe token
Keyboard focus3px --color-focus outline (inset by 1px)the token
Grip4×24px pill (24×4px when vertical), --color-text-muted at 50% opacity, 80% on hover.split-divider::after
Cursorcol-resize / row-resize—
Forced coloursDivider CanvasText, grip Canvas, hover/focus Highlight—
Reduced motionColour transition switched off—

Once enhanced, the container gets flex-wrap: nowrap (and flex-direction: column when vertical), and every panel loses its minimum content size so it can shrink beside the divider. The script also writes inline flex-grow, flex-shrink, flex-basis and overflow: auto on the first two panels, so your own CSS for those properties on the panels is overridden.

Dynamic Elements

Splitter containers added to the DOM after page load are automatically enhanced via a MutationObserver. No manual initialization is needed.

Accessibility

  • role="separator" identifies the divider as a resizable boundary to screen readers
  • aria-valuenow, aria-valuemin, and aria-valuemax convey position and range
  • aria-orientation is the divider's own axis (vertical for side-by-side panels)
  • aria-label (default "Resize panels", override with data-label-resize) provides the accessible name; aria-controls names the resized panel
  • Pointer drag and arrow keys are direction-aware: in RTL the first panel is on the right and the controls mirror
  • A cancelled drag (pointercancel, lost capture) ends cleanly, restoring text selection
  • tabindex="0" makes the divider keyboard-focusable with a visible focus ring
  • Full keyboard navigation: Arrow keys, Shift+Arrow, Home, and End
  • The divider traps neither focus nor mouse — panel content remains fully interactive
  • Without JavaScript, panels render in normal flow — progressive enhancement

Related

↑