Resizable Panels

View as Markdown

Panels with handles you drag or move with the keys. Sizes are kept between visits.

  • Mira PatelQ3 launch checklist: two items left
  • Ben OkaforRe: Checkout errors since the 5 PM deploy
  • BillingYour invoice for November is ready
  • Aleksandra Wiśniewska-KowalczykContract review: redlines on sections 4 and 7 attached

Re: Checkout errors since the 5 PM deploy

Rolled back the payment client. Error rate is back under 0.1%. I'll write up what happened tomorrow morning, and we can decide whether the retry change goes out again on Thursday.

When to use

Panels with handles you drag or move with the keys. Sizes are kept between visits. Use Scroll Area instead when the content needs to scroll, not to take more room.

Usage

import { Resizable } from "./ui/uicontext/components/Resizable.ts"
export const DocWithPreview = <M>(h: Html.H<M>, editor: View.Content<M>, preview: View.Content<M>) =>	Resizable(h, {		label: "Editor and preview",		storageKey: "doc-preview",		panels: [			{ id: "editor", label: "Editor", defaultSize: 50, min: 30, content: editor },			{ id: "preview", label: "Preview", defaultSize: 50, min: 20, collapsible: true, content: preview },		],	})

Examples

Stacked

direction: "vertical": the arrow keys move the handle up and down.

export const retry = (attempt: number) =>
  Math.min(30_000, 2 ** attempt * 250)
$ bun test retry
✓ backs off exponentially (2 ms)
✓ caps at 30 seconds (1 ms)

2 passed

API reference

ResizablePartsComponent

Props

ResizableParts props
NameTypeDescription
labelrequiredstringWhat the group is: "Mail".
panelsrequiredResizablePanel[]—
direction"horizontal" | "vertical"—
storageKeystringKeeps the sizes in this browser under this key. Without it they reset on reload.

Events

ResizableParts events
EventPayloadDescription
RequestedResize{ sizes: Sizes }The sizes the person settled on, after a drag, a key or a fold: for an app that keeps them on its server.

ResizableView function

Options

Resizable options
NameTypeDefaultDescription
keystring—Names the group among others in the same view; needed for more than one.
labelrequiredstring—What the group is: "Mail".
panelsrequiredReadonlyArray<ResizablePanel & { readonly content: View.Content }>——
direction"horizontal" | "vertical"horizontalSide by side, or stacked; horizontal by default.
storageKeystring—Keeps the sizes in this browser under this key, so the layout comes back after a reload.
onResize(sizes: number[]) => Message—The sizes the person settled on, for an app that keeps them on its server.
styleStyle—StyleX styles applied after the group's own.

Keyboard and accessibility

KeysDoes
Left arrow Right arrowMove the handle by a small step
Shift Left arrow Shift Right arrowMove the handle by a large step
Home EndShrink or grow the panel to its limit
EnterFold the panel, or unfold it

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/resizable-panels

Source