Skip to main content
196

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Web docs
Editors and workspaces

useResizable

Provides pane sizing props and separator handle props for horizontal or vertical resizable groups.

Live component preview · Astro

Explore Resizable

Try the component this hook connects to. The preview uses the Astro adapter; the React example below uses useResizable.

Editor

Drag a separator or focus it and use Arrow Left / Arrow Right.

Preview

Double-click a separator to reset pane sizes.

React usage

Import from @santi020k/lumen-react and spread the controller props onto the matching components.

tsxuseResizable example
import { Resizable } from '@santi020k/lumen-react'

export function SplitEditor() {
  return (
    <Resizable defaultSizes={[30, 70]}>
      <aside>Navigation</aside>
      <main>Editor</main>
    </Resizable>
  )
}
import { Resizable } from '@santi020k/lumen-react'

export function SplitEditor() {
  return (
    <Resizable defaultSizes={[30, 70]}>
      <aside>Navigation</aside>
      <main>Editor</main>
    </Resizable>
  )
}

Load @santi020k/lumen-react/styles.css once in your application. With React Server Components, put 'use client' at the top of the module that calls the hook. Follow the React setup guide for the framework boundary.

Options

PropertyTypeDefaultDescription
panelCountnumber2Number of panes in the group.
defaultSizesnumber[]equal panesInitial pane sizes normalized to 100%.
minSizenumber | number[]12Minimum pane size percentage.
maxSizenumber | number[]88Maximum pane size percentage.
direction"horizontal" | "vertical""horizontal"Resize axis and generated separator orientation.
resetOnDoubleClickbooleantrueReset panes to their default sizes on handle double-click.
onSizesChange(sizes: number[]) => void-Callback fired when panes are resized.

Controller return values

PropertyTypeDescription
rootPropsLumenProps<"div">Spread onto the resizable root.
getPanelProps(index, props?) => LumenProps<"div">Returns data/style props for a pane.
getHandleProps(index, props?) => LumenProps<"button">Returns separator handle props with pointer and keyboard handlers.
sizesnumber[]Current pane sizes as percentages.
resizePair(index, nextSize) => voidResize one pane and its following pane while honoring min/max.
reset() => voidReset to the normalized default sizes.
Web docsFull catalog