# Resizable

Keyboard and pointer resizable panel composition.

Keyboard and pointer resizable panel composition.

```tsx
import { Resizable } from "@zentara-co/zenos-ui";

function ResizableExample() {
  return (
    <Resizable.Root aria-label="Workspace" className="h-40 w-full max-w-xl">
      <Resizable.Panel className="grid place-items-center">Editor</Resizable.Panel>
      <Resizable.Handle aria-label="Resize editor" />
      <Resizable.Panel className="grid place-items-center">Preview</Resizable.Panel>
    </Resizable.Root>
  );
}
```

## Import

```tsx
import { Resizable } from "@zentara-co/zenos-ui";
```

## Orientation

Horizontal roots place panels side by side and expose a vertical separator. Vertical roots stack panels and expose a horizontal separator.

The default handle keeps an 8px interaction target around a centered 1px separator. Its line uses the focused border color on hover, while pressed, and during keyboard focus, making the resize affordance visible without widening the panel gap.

```tsx
import { Resizable } from "@zentara-co/zenos-ui";

function ResizableVerticalExample() {
  return (
    <Resizable.Root
      orientation="vertical"
      defaultValue={[35, 65]}
      aria-label="Vertical workspace"
      className="h-72 w-full max-w-xl rounded-lg border border-border-default"
    >
      <Resizable.Panel className="grid place-items-center bg-background-neutral-subtle">
        Activity
      </Resizable.Panel>
      <Resizable.Handle aria-label="Resize activity and details" />
      <Resizable.Panel className="grid place-items-center">Details</Resizable.Panel>
    </Resizable.Root>
  );
}
```

## Controlled sizes

Panel values are percentages and are normalized to total 100. In controlled mode, update `value` from `onValueChange` to reflect pointer and keyboard requests.

```tsx
import { Resizable, Stack, Text } from "@zentara-co/zenos-ui";
import { useState } from "react";

function ResizableControlledExample() {
  const [sizes, setSizes] = useState([40, 60]);
  return (
    <Stack gap="3" className="w-full max-w-xl">
      <Resizable.Root
        value={sizes}
        onValueChange={setSizes}
        keyboardStep={10}
        aria-label="Controlled workspace"
        className="h-48 rounded-lg border border-border-default"
      >
        <Resizable.Panel className="grid place-items-center">Editor</Resizable.Panel>
        <Resizable.Handle aria-label="Resize editor and preview" />
        <Resizable.Panel className="grid place-items-center bg-background-neutral-subtle">
          Preview
        </Resizable.Panel>
      </Resizable.Root>
      <Text size="s" color="subtle">
        Editor {Math.round(sizes[0] ?? 0)}% · Preview {Math.round(sizes[1] ?? 0)}%
      </Text>
    </Stack>
  );
}
```

## Panel constraints

`minSize` and `maxSize` constrain adjacent panel percentages. Every handle resizes the panel immediately before and after it.

```tsx
import { Resizable } from "@zentara-co/zenos-ui";

function ResizableConstraintsExample() {
  return (
    <Resizable.Root
      defaultValue={[25, 50, 25]}
      aria-label="Three-panel workspace"
      className="h-48 w-full rounded-lg border border-border-default"
    >
      <Resizable.Panel minSize={20} maxSize={40} className="grid place-items-center">
        Navigation
      </Resizable.Panel>
      <Resizable.Handle aria-label="Resize navigation and content" />
      <Resizable.Panel
        minSize={30}
        className="grid place-items-center bg-background-neutral-subtle"
      >
        Content
      </Resizable.Panel>
      <Resizable.Handle aria-label="Resize content and inspector" />
      <Resizable.Panel minSize={20} maxSize={40} className="grid place-items-center">
        Inspector
      </Resizable.Panel>
    </Resizable.Root>
  );
}
```

## Disabled

A disabled root prevents pointer and keyboard resizing and removes its handles from the tab order.

```tsx
import { Resizable } from "@zentara-co/zenos-ui";

function ResizableDisabledExample() {
  return (
    <Resizable.Root
      disabled
      defaultValue={[50, 50]}
      aria-label="Locked workspace"
      className="h-36 w-full max-w-xl rounded-lg border border-border-default"
    >
      <Resizable.Panel className="grid place-items-center">Editor</Resizable.Panel>
      <Resizable.Handle aria-label="Resize disabled" />
      <Resizable.Panel className="grid place-items-center bg-background-neutral-subtle">
        Preview
      </Resizable.Panel>
    </Resizable.Root>
  );
}
```

## Variants

orientation: horizontal, orientation: vertical

## Anatomy

```text
Resizable.Root
Resizable.Panel
Resizable.Handle
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| value | number[] | — | Controlled panel percentages. |
| defaultValue | number[] | — | Initial panel percentages. |
| onValueChange | (sizes: number[]) => void | — | Runs while panels resize. |
| orientation | horizontal \| vertical | horizontal | Panel flow direction. |
| keyboardStep | number | 5 | Percentage changed by arrow keys. |
| disabled | boolean | false | Disables resize interaction. |
| Panel.defaultSize | number | — | Initial percentage when Root.defaultValue is omitted. |
| Panel.minSize / maxSize | number | 0 / 100 | Constrains the panel percentage during resizing. |
| Handle.children | ReactNode | — | Optional visual rendered at the separator center. |
| native props | React.HTMLAttributes<HTMLDivElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

Each handle is a focusable separator with orientation and current, minimum, and maximum percentage values. Give every handle a label that identifies the adjacent panels. Left and Right Arrow resize horizontal panels; Up and Down Arrow resize vertical panels. Home and End move to the permitted minimum and maximum. Visible focus remains on the handle throughout keyboard resizing.

Source: https://zenos-ui.pages.dev/components/resizable/