Splits an area into panels that you resize with a pointer or the keyboard.
Design brief
Northwind wants a calmer checkout: three steps, no account prompt.
- Address and delivery
- Payment
- Review
Preview
Checkout
1 Address · 2 Payment · 3 Review
Free delivery over $50
The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.
ResizableGroupOwns the layout. Save it in onLayoutEnd.
ResizablePanelRepeatsAn id names the panel in the group. Put padding on a child so a collapsed panel can reach zero.
ResizableHandleRepeatsPut one between each pair of panels.
ResizableHandleIndicatorOptionalUses the machine resize-trigger indicator.
ResizableContext Renders a function with the splitter api. useResizable also returns the registered panels and handles.
deploy.ts
export async function deploy() {
const build = await buildApp();
await upload(build);
return promote(build.id);
}$ pnpm deploy
Build finished in 12.4s
Uploaded 148 files
Live at northwind.example.com
Files
- checkout.tsx
- cart.ts
- totals.test.ts
checkout.tsx
export function Checkout() {
return <Steps value={step} />;
}$ pnpm test totals
3 tests passed
Set minSize and maxSize on a panel to limit it.
Shipping policy
Orders leave the warehouse within one business day. Express orders placed before 2 PM ship the same day.
Inspector
- Owner
- Maya Chen
- Updated
- 2 hours ago
- Words
- 1,240
Press Enter on the handle to collapse the panel.
Outline
- Summary
- Requirements
- Open questions
Summary
Northwind wants a calmer checkout: three steps, no account prompt, and the delivery date before payment.
Save the layout in onLayoutEnd and pass it back as defaultLayout.
Also install Prompt input and Code block.
You
Make the empty state calmer and remove the second button.
Assistant
I moved the empty state into its own component and kept one action. The diff is on the right.
export function EmptyState() { return ( <section className="grid place-items-center p-8"> <h2>No projects yet</h2> <p>Create a project to start a review.</p> </section> );}ResizableContext gives the splitter api to custom UI. Also install Button.
Draft
Calmer checkout
Keep three steps and remove the account prompt. Confirm the address before payment.
- 1Address and delivery
- 2Payment
- 3Review
Layout
50% / 50%
- Panels
- 0
- State
- Idle
ResizableGroup
Collects the panels and handles. Zag owns the sizes, the drag and key handling, and the collapse state.
- orientation: "horizontal" | "vertical" = "horizontal"
- Sets the axis. A horizontal group puts panels in a row, with vertical separators.
- layout: number[]
- Controls the sizes as percentages that sum to 100. The group calls onLayoutChange for each change.
- defaultLayout: number[]
- Sets the sizes at first and after a double-click on a handle.
- onLayoutChange: (layout: number[]) => void
- Receives every size change, including each frame of a drag.
- onLayoutEnd: (layout: number[]) => void
- Receives the final sizes at the end of a drag or a key press. Use it to save the layout.
- onResizeStart: () => void
- Called when a drag or a key resize starts.
- keyboardResizeBy: number | null
- Sets the pixel step for the arrow keys.
- nonce: string
- Sets the nonce for the injected cursor stylesheet.
- onCollapse: (details: { panelId: string; size: number }) => void
- Called when a panel collapses.
- onExpand: (details: { panelId: string; size: number }) => void
- Called when a panel expands.
- registry: SplitterRegistry
- Shares drag state between nested splitters so an intersection resizes both.
- dir: "ltr" | "rtl"
- Sets the writing direction in the machine.
- ids: ElementIds
- Sets the ids of the root, panels, and triggers.
ResizablePanel
Sets its starting share of the group. Put padding on a child so a collapsed panel can reach zero.
- id: string
- Sets the panel DOM id, so a handle points at it with aria-controls. Panels without it get a generated id.
- order: number
- Orders the panel in the machine when panels render conditionally.
- defaultSize: number | string
- Sets the share of the group. Panels without it share the free space equally.
- minSize: number | string = 10
- Sets the smallest size a drag or a key press can give the panel.
- maxSize: number | string = 100
- Sets the largest size a drag or a key press can give the panel.
- collapsible: boolean = false
- Lets the panel collapse to collapsedSize when it is dragged past half of minSize, or with Enter on the handle.
- collapsedSize: number | string = 0
- Sets the size of a collapsed panel.
- resizeBehavior: "preserve-relative-size" | "preserve-pixel-size"
- Sets how the panel behaves when the group resizes.
ResizableHandle
Drags with a pointer, moves with the arrow keys, and resets the layout on a double-click.
- withGrip: boolean = false
- Shows a grip pill in the middle of the line.
- isDisabled: boolean = false
- Stops the handle from resizing.
- aria-label: string = "Resize panels"
- Names the separator.
ResizableHandleIndicator
Draws the machine resize-trigger indicator inside a handle. The handle supplies the trigger id.
- triggerId: string
- Overrides the trigger id from the enclosing handle.
ResizableContext
Renders no DOM. Its children receive the splitter api: dragging, getSizes, setSizes, getPanels, getPanelSize, collapsePanel, expandPanel, resizePanel, getLayout, and resetSizes.
- children: (api: SplitterApi) => ReactNodeRequired
- Draws custom content inside ResizableGroup.