Skip to content
2k
On This Page

Resizable

Accessible resizable panel groups and layouts with keyboard support.

One
Two
Three
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup
} from "~/components/ui/resizable"

export default function ResizableDemo() {
  return (
    <ResizablePanelGroup
      orientation="horizontal"
      class="h-[200px] max-w-sm rounded-lg border"
    >
      <ResizablePanel defaultSize={50}>
        <div class="flex h-[200px] items-center justify-center p-6">
          <span class="font-semibold">One</span>
        </div>
      </ResizablePanel>
      <ResizableHandle withHandle aria-label="Resize files" />
      <ResizablePanel defaultSize={50}>
        <ResizablePanelGroup orientation="vertical">
          <ResizablePanel defaultSize={25}>
            <div class="flex h-full items-center justify-center p-6">
              <span class="font-semibold">Two</span>
            </div>
          </ResizablePanel>
          <ResizableHandle withHandle aria-label="Resize editor panels" />
          <ResizablePanel defaultSize={75}>
            <div class="flex h-full items-center justify-center p-6">
              <span class="font-semibold">Three</span>
            </div>
          </ResizablePanel>
        </ResizablePanelGroup>
      </ResizablePanel>
    </ResizablePanelGroup>
  )
}

About

The Resizable component styles UI SDK Resizable panels and handles.

Installation

pnpm dlx solidui-cli@latest add resizable

Install the following dependencies:

pnpm add @ui-sdk/solid @ui-sdk/core

Copy and paste the following code into your project.

components/ui/resizable.tsx
import type { ComponentProps } from "@solidjs/web"
import {
  Resizable as SdkResizable,
  ResizablePanel as SdkResizablePanel,
  ResizableHandle as SdkResizableHandle
} from "@ui-sdk/solid/resizable"
import { omit } from "solid-js"

import { cn } from "~/lib/utils"

export function ResizablePanelGroup(
  props: Omit<ComponentProps<typeof SdkResizable>, "class"> & { class?: string }
) {
  return (
    <SdkResizable
      {...props}
      class={cn(
        "flex h-full w-full data-[orientation=vertical]:flex-col",
        props.class
      )}
    />
  )
}

export function ResizablePanel(
  props: Omit<ComponentProps<typeof SdkResizablePanel>, "class"> & {
    class?: string
  }
) {
  return (
    <SdkResizablePanel {...props} class={cn("min-h-0 min-w-0", props.class)} />
  )
}

export function ResizableHandle(
  props: Omit<ComponentProps<typeof SdkResizableHandle>, "class"> & {
    class?: string
    withHandle?: boolean
  }
) {
  const rest = omit(props, "class", "withHandle")
  return (
    <SdkResizableHandle
      {...rest}
      class={cn(
        "relative flex w-px shrink-0 items-center justify-center bg-border outline-none focus-visible:ring-1 focus-visible:ring-ring data-[orientation=vertical]:h-px data-[orientation=vertical]:w-full",
        props.class
      )}
    >
      {props.withHandle && (
        <div class="h-6 w-1 rounded-lg bg-border z-10 flex shrink-0" />
      )}
    </SdkResizableHandle>
  )
}

Update the import paths to match your project setup.

Usage

import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup
} from "~/components/ui/resizable"
<ResizablePanelGroup orientation="horizontal">
  <ResizablePanel defaultSize={50}>Files</ResizablePanel>
  <ResizableHandle aria-label="Resize panels" />
  <ResizablePanel defaultSize={50}>Editor</ResizablePanel>
</ResizablePanelGroup>

Use orientation, onLayoutChange, and onLayoutCommit on ResizablePanelGroup. Each panel accepts defaultSize, minSize, maxSize, and collapsible. Percentages are numbers. Name each handle with aria-label. Native SDK controllers replace React panel refs.

See the UI SDK resizable API for native options and keyboard behavior.

Composition

Use the following composition to build a ResizablePanelGroup:

ResizablePanelGroup
├── ResizablePanel
├── ResizableHandle
└── ResizablePanel

Vertical

Use orientation="vertical" for vertical resizing.

Header
Content
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup
} from "~/components/ui/resizable"

export default function ResizableVertical() {
  return (
    <ResizablePanelGroup
      orientation="vertical"
      class="min-h-[200px] max-w-sm rounded-lg border"
    >
      <ResizablePanel defaultSize={25}>
        <div class="flex h-full items-center justify-center p-6">
          <span class="font-semibold">Header</span>
        </div>
      </ResizablePanel>
      <ResizableHandle aria-label="Resize panels" />
      <ResizablePanel defaultSize={75}>
        <div class="flex h-full items-center justify-center p-6">
          <span class="font-semibold">Content</span>
        </div>
      </ResizablePanel>
    </ResizablePanelGroup>
  )
}

Handle

Use the withHandle prop on ResizableHandle to show a visible handle.

Sidebar
Content
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup
} from "~/components/ui/resizable"

export default function ResizableHandleDemo() {
  return (
    <ResizablePanelGroup
      orientation="horizontal"
      class="min-h-[200px] max-w-md rounded-lg border md:min-w-[450px]"
    >
      <ResizablePanel defaultSize="25%">
        <div class="flex h-full items-center justify-center p-6">
          <span class="font-semibold">Sidebar</span>
        </div>
      </ResizablePanel>
      <ResizableHandle withHandle />
      <ResizablePanel defaultSize="75%">
        <div class="flex h-full items-center justify-center p-6">
          <span class="font-semibold">Content</span>
        </div>
      </ResizablePanel>
    </ResizablePanelGroup>
  )
}

API Reference

See the UI SDK Resizable API for layout, sizing, and keyboard controls.