Skip to Content
CodeUI

Resizable

@codeui/styles v0.3.0

The handle between two resizable panels, in plain HTML.

Load @codeui/styles/resizable.css, or all.css. The Solid component is documented in Resizable.

Demo

resizable/basic.html
<div data-cui="resizable" style="display: flex; flex-direction: row; height: 160px">  <div data-cui="resizable-panel" style="flex: none; flex-basis: 40%; overflow: hidden"><div style="padding: 16px">Threads</div></div>  <button type="button" role="separator" aria-label="Resize panels" aria-orientation="horizontal" aria-valuenow="0.4" aria-valuemin="0" aria-valuemax="1" class="cui-resizable-handle" data-cui="resizable-handle" data-orientation="horizontal"></button>  <div data-cui="resizable-panel" style="flex: none; flex-basis: 60%; overflow: hidden"><div style="padding: 16px">Conversation</div></div></div>

Markup

PartElementClassdata-cui
Rootdivnoneresizable
Paneldivnoneresizable-panel
Handlebutton type="button" with role="separator"cui-resizable-handleresizable-handle

Only the handle has styles. Give the root display: flex (flex-direction: column when vertical) and a size, and give each panel flex: none, overflow: hidden and a flex-basis.

AttributeValuesDefault
data-orientation on the handlehorizontal, verticalhorizontal
data-active on the handlePresence: hovered, focused or draggedOff
data-dragging on the handlePresenceOff

Variants

Vertical

resizable/vertical.html
<div data-cui="resizable" style="display: flex; flex-direction: column; height: 240px">  <div data-cui="resizable-panel" style="flex: none; flex-basis: 40%; overflow: hidden"><div style="padding: 16px">Threads</div></div>  <button type="button" role="separator" aria-label="Resize panels" aria-orientation="vertical" aria-valuenow="0.4" aria-valuemin="0" aria-valuemax="1" class="cui-resizable-handle" data-cui="resizable-handle" data-orientation="vertical"></button>  <div data-cui="resizable-panel" style="flex: none; flex-basis: 60%; overflow: hidden"><div style="padding: 16px">Conversation</div></div></div>

data-orientation="vertical" draws a horizontal line and a row-resize cursor.

States

The line is --cui-border-divider at rest, --cui-surface-scroll-thumb on hover and with data-active, --cui-surface-scroll-thumb-hover with data-dragging, and 2px of --cui-focus-color on :focus-visible. The colour changes over 120ms, except on keyboard focus. In an island layout, set --cui-resizable-handle-line-color: transparent: the gap between islands already separates them.

What you supply

  • Dragging and keyboard resizing: arrow keys by a step, Home and End to the limits, Enter to collapse.
  • aria-orientation, aria-controls, aria-valuenow, aria-valuemin and aria-valuemax on the handle, and an aria-label.

Helper

import "@codeui/styles/resizable.css";
import { applyStyleProps } from "@codeui/styles";
import { resizableStyleProps } from "@codeui/styles/resizable";

const handle = document.querySelector<HTMLElement>("[role=separator]")!;
applyStyleProps(handle, resizableStyleProps({ orientation: "vertical" }));
// class="cui-resizable-handle" data-cui="resizable-handle" data-orientation="vertical"

On this page