Skip to the content
human-kit design
46 — Layout

Resizable

Two panels and a line between them, dragged or moved with the keys to share the space.

Patients 38%
AM
Ana María Ruiz IVF, second cycle
Stimulation
Next
Ultrasound, 3 Dec, 8:30
Doctor
Dr. Julián Ortega
  1. Ultrasound
  2. Stimulation started

Installation

pnpm dlx @human-kit/design add resizable
npx @human-kit/design add resizable
yarn dlx @human-kit/design add resizable
bunx @human-kit/design add resizable

The command copies the files to src/lib/components/ui/resizable. It also installs the packages that the files import.

Usage

<script lang="ts">
	import * as Resizable from '$lib/components/ui/resizable';

	let size = $state(35);
</script>

<Resizable.Root bind:size label="Resize the patient list" class="h-96">
	{#snippet start()}<PatientList />{/snippet}
	{#snippet end()}<PatientDetail />{/snippet}
</Resizable.Root>

Examples

One over the other

orientation="vertical" stacks the panels and the line runs across. The up and down arrows move it.

Ultrasound, 1 December Day 9
Left ovary
  • 18 mm
  • 17 mm
  • 16 mm
  • 14 mm
  • 12 mm
Right ovary
  • 19 mm
  • 17 mm
  • 15 mm
  • 13 mm
  • 11 mm
  • 10 mm
Notes 45%
  • Good response on day 9: six follicles at 15 mm or more.
  • Endometrium 9.2 mm, trilaminar.
  • Keep the dose. Trigger likely on day 11 if the lead follicles pass 18 mm.
  • Blood test for oestradiol tomorrow at 7:00.

Guidelines

  • Use it for two views that are read together and that people size to their task: a list and its detail, a record and its notes.
  • Give the container a height: the panels fill it, and each scrolls on its own inside, with a ScrollArea.Root.
  • Set min and max so that neither panel can get too narrow to be read. The defaults keep each one at 15% or more.
  • Keep size in the user's settings through onSizeChange, so the split is the same at the next visit.
  • On a narrow screen, show one panel at a time instead of a split.

Accessibility

  • The line is a role="separator" that takes the focus, with its value in aria-valuenow, aria-valuemin and aria-valuemax: the share of the first panel.
  • Name it in label by what it resizes, as "Resize the patient list". The default is "Resize the panels".
  • The arrows move it by 2%, Shift and an arrow by 10%, Home and End to min and max. Side by side, the arrows turn round when the text runs right to left.
  • The line is 1px, but the strip that takes the pointer is 13px wide, and a press on it moves the focus to it.

API reference

PropTypeDefault
startSnippet

The first panel: on the left, or on top.

—
endSnippet

The second panel, which takes the rest of the space.

—
sizenumber

The first panel's share, in percent. Bindable.

50
minnumber

The smallest share of the first panel.

15
maxnumber

The largest share of the first panel.

85
orientation'horizontal' | 'vertical'

Side by side, or one over the other.

'horizontal'
labelstring

The line's name, read aloud: what it resizes.

'Resize the panels'
onSizeChange(size: number) => void

Called with the new share as the line moves.

—
classstring

Classes for the container.

—

It takes no other attributes: put an id or a role on an element around it.