Resizable

Panels people resize by dragging the line between them.

import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '@halo-ds/react';

When to use it

Use Resizable when people need to balance two or three areas, like a file list beside a preview or an editor beside its output. In Figma, place a Resizable handle between two panel frames and stretch it to their height.

Do

  • Set a minimum size so panels never shrink to nothing.
  • Turn on Grip when the line is hard to spot.
  • Save the layout so it is the same next time.
  • Give each handle a name for screen readers, like Resize file list.

Don't

  • Use it on phones; stack the content or use tabs instead.
  • Put more than three panels in one row.
  • Resize panels that hold a single short item.
  • Hide important actions in a panel that can shrink away.

Props

ResizablePanelGroup props

PropTypeWhat it does
direction`Direction \undefined`Side by side, or stacked. Figma: Direction.
onLayout`((sizes: number[]) => void) \undefined`Called with each panel's size, in percent, after it changes. Save it to restore the layout later.
children (required)ReactNode
classNames`Partial<Record<ResizablePart, string>> \undefined`Extra class names for the parts inside the component, by part name, like { header: 'my-header' }.
styles`Partial<Record<ResizablePart, CSSProperties>> \undefined`Inline styles for the parts inside the component, by part name, like { footer: { gap: 4 } }.

It also takes the usual HTML attributes for its element.

ResizablePanel props

PropTypeWhat it does
defaultSize`number \undefined`Starting size, in percent of the group. Panels without one share what's left.
minSize`number \undefined`Smallest size, in percent. Default 10.
maxSize`number \undefined`Largest size, in percent. Default 90.
index`number \undefined`Set by the group.

It also takes the usual HTML attributes for its element.

ResizableHandle props

PropTypeWhat it does
withHandle`boolean \undefined`Shows a grip in the middle, so the handle is easy to find. Figma: Grip.
aria-label`string \undefined`Screen reader name, like "Resize sidebar".
index`number \undefined`Set by the group.

It also takes the usual HTML attributes for its element.

Examples

Overview

import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@halo-ds/react';

const pane = { display: 'grid', placeItems: 'center', height: '100%', color: 'var(--halo-text-secondary)', fontWeight: 600 } as const;

export default function Example() {
  return (
    <div style={{ width: '100%', height: 260, borderRadius: 16, overflow: 'hidden', boxShadow: 'inset 0 0 0 1px var(--halo-border-secondary)' }}>
      <ResizablePanelGroup direction="horizontal">
        <ResizablePanel defaultSize={30} minSize={20}>
          <div style={pane}>Files</div>
        </ResizablePanel>
        <ResizableHandle withHandle aria-label="Resize file list" />
        <ResizablePanel>
          <div style={pane}>Preview</div>
        </ResizablePanel>
      </ResizablePanelGroup>
    </div>
  );
}

Stacked and nested

A top area over a bottom area split in two.

import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@halo-ds/react';

const pane = { display: 'grid', placeItems: 'center', height: '100%', color: 'var(--halo-text-secondary)', fontWeight: 600 } as const;

export default function Demo() {
  return (
    <div style={{ width: '100%', height: 300, borderRadius: 16, overflow: 'hidden', boxShadow: 'inset 0 0 0 1px var(--halo-border-secondary)' }}>
      <ResizablePanelGroup direction="vertical">
        <ResizablePanel defaultSize={50}>
          <div style={pane}>Editor</div>
        </ResizablePanel>
        <ResizableHandle withHandle aria-label="Resize editor" />
        <ResizablePanel>
          <ResizablePanelGroup direction="horizontal">
            <ResizablePanel defaultSize={50}>
              <div style={pane}>Console</div>
            </ResizablePanel>
            <ResizableHandle withHandle aria-label="Resize console" />
            <ResizablePanel>
              <div style={pane}>Preview</div>
            </ResizablePanel>
          </ResizablePanelGroup>
        </ResizablePanel>
      </ResizablePanelGroup>
    </div>
  );
}

More: https://halodesignsystem.dev/components/resizable