Resizable

Panels side by side, shared evenly at first and resized by dragging the handle between them or with its arrow keys, on react-resizable-panels.

Item 1
Item 2
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@produkto/ui/Resizable";

const Example = () => (
  <ResizablePanelGroup className="min-h-50 max-w-sm rounded-lg border border-border">
    <ResizablePanel>
      <div className="flex h-full items-center justify-center p-6">
        <span className="label-sm">Item 1</span>
      </div>
    </ResizablePanel>
    <ResizableHandle />
    <ResizablePanel>
      <div className="flex h-full items-center justify-center p-6">
        <span className="label-sm">Item 2</span>
      </div>
    </ResizablePanel>
  </ResizablePanelGroup>
);

export default Example;

Usage

import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@produkto/ui/Resizable";
<ResizablePanelGroup>
  <ResizablePanel>Item 1</ResizablePanel>
  <ResizableHandle />
  <ResizablePanel>Item 2</ResizablePanel>
</ResizablePanelGroup>

Examples

Orientation

orientation="vertical" stacks the panels, the handle between them moving up and down, beside panels side by side as they are by default.

Item 1
Item 2
Item 1
Item 2
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@produkto/ui/Resizable";

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    <ResizablePanelGroup className="min-h-50 rounded-lg border border-border">
      <ResizablePanel>
        <div className="flex h-full items-center justify-center p-6">
          <span className="label-sm">Item 1</span>
        </div>
      </ResizablePanel>
      <ResizableHandle />
      <ResizablePanel>
        <div className="flex h-full items-center justify-center p-6">
          <span className="label-sm">Item 2</span>
        </div>
      </ResizablePanel>
    </ResizablePanelGroup>
    <ResizablePanelGroup
      className="min-h-50 rounded-lg border border-border"
      orientation="vertical"
    >
      <ResizablePanel>
        <div className="flex h-full items-center justify-center p-6">
          <span className="label-sm">Item 1</span>
        </div>
      </ResizablePanel>
      <ResizableHandle />
      <ResizablePanel>
        <div className="flex h-full items-center justify-center p-6">
          <span className="label-sm">Item 2</span>
        </div>
      </ResizablePanel>
    </ResizablePanelGroup>
  </div>
);

export default Example;

Show handle

showHandle draws a grip on the handle's line, so the place to drag reads at a glance, where by default the handle is the line alone.

Item 1
Item 2
Item 1
Item 2
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@produkto/ui/Resizable";

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    <ResizablePanelGroup className="min-h-50 rounded-lg border border-border">
      <ResizablePanel>
        <div className="flex h-full items-center justify-center p-6">
          <span className="label-sm">Item 1</span>
        </div>
      </ResizablePanel>
      <ResizableHandle />
      <ResizablePanel>
        <div className="flex h-full items-center justify-center p-6">
          <span className="label-sm">Item 2</span>
        </div>
      </ResizablePanel>
    </ResizablePanelGroup>
    <ResizablePanelGroup className="min-h-50 rounded-lg border border-border">
      <ResizablePanel>
        <div className="flex h-full items-center justify-center p-6">
          <span className="label-sm">Item 1</span>
        </div>
      </ResizablePanel>
      <ResizableHandle showHandle />
      <ResizablePanel>
        <div className="flex h-full items-center justify-center p-6">
          <span className="label-sm">Item 2</span>
        </div>
      </ResizablePanel>
    </ResizablePanelGroup>
  </div>
);

export default Example;

Min and max size

minSize and maxSize hold a panel between two sizes however far its handle is dragged, where by default it can shrink to nothing or fill the group.

Item 1
Item 2
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@produkto/ui/Resizable";

const Example = () => (
  <ResizablePanelGroup className="min-h-50 max-w-sm rounded-lg border border-border">
    <ResizablePanel maxSize="75%" minSize="25%">
      <div className="flex h-full items-center justify-center p-6">
        <span className="label-sm">Item 1</span>
      </div>
    </ResizablePanel>
    <ResizableHandle />
    <ResizablePanel>
      <div className="flex h-full items-center justify-center p-6">
        <span className="label-sm">Item 2</span>
      </div>
    </ResizablePanel>
  </ResizablePanelGroup>
);

export default Example;

Collapsible

collapsible folds a panel away once it is dragged below its minSize, where by default it stops there; Enter on the handle folds and opens it too.

Item 1
Item 2
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@produkto/ui/Resizable";

const Example = () => (
  <ResizablePanelGroup className="min-h-50 max-w-sm rounded-lg border border-border">
    <ResizablePanel collapsible minSize="25%">
      <div className="flex h-full items-center justify-center p-6">
        <span className="label-sm">Item 1</span>
      </div>
    </ResizablePanel>
    <ResizableHandle />
    <ResizablePanel>
      <div className="flex h-full items-center justify-center p-6">
        <span className="label-sm">Item 2</span>
      </div>
    </ResizablePanel>
  </ResizablePanelGroup>
);

export default Example;

API Reference

It takes no props.

ResizablePanelGroup

ResizablePanelGroupProps · also takes the props of react-resizable-panels Group
PropTypeDefault
orientation"horizontal" | "vertical""horizontal"

ResizablePanel

ResizablePanelProps · takes the props of react-resizable-panels Panel

ResizableHandle

ResizableHandleProps · also takes the props of react-resizable-panels Separator
PropTypeDefault
showHandlebooleanfalse