suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Components84
  • Overview
  • Accordion
  • Alert
  • Alert Dialog
  • Alert Sheet
  • Amount Input
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Bottom Bar
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Chip
  • Code Block
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Direction
  • Drawer
  • Dropdown Menu
  • Empty
  • FAB
  • Field
  • Fullscreen Menu
  • Haptics
  • Header
  • Hover Card
  • Icon
  • Input
  • Input Accessory Bar
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Keyboard Scroll View
  • Keypad
  • Label
  • Marker
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Page Indicator
  • Pagination
  • Pin Pad
  • Popover
  • Progress
  • QR Scanner
  • Questionnaire
  • Radio Group
  • Resizable
  • Screen
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature Pad
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Tab Bar
  • Table
  • Tabs
  • Text
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Trace
  • Wheel Picker
  • Widget

suiss/ui · Component

Resizable

Panels separated by draggable handles that let users resize sections of a layout.

Resizable is an open-source component from suiss/ui for React. The @esuiss/ui CLI copies its source into your project, so you own the code.

import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/components/ui/resizable"

export default function ResizableDemo() {
  return (
    <div className="h-80 w-[36rem] overflow-hidden rounded-2xl border">
      <ResizablePanelGroup orientation="horizontal">
        <ResizablePanel defaultSize="50%">
          <div className="flex h-full items-center justify-center p-6 text-sm font-medium">
            Inbox
          </div>
        </ResizablePanel>
        <ResizableHandle />

Resizable wraps react-resizable-panels. ResizablePanelGroup lays out its children in a row or column, alternating ResizablePanel and ResizableHandle. Drag a handle, or focus it and use the keyboard, to change the size of the panels on either side. Groups can be nested to build multi-pane layouts such as an editor with a sidebar and a terminal.

The cards variant renders each panel as a rounded card with a pill-shaped grip between them. Use Resizable for user-adjustable layouts; use Sidebar for a standard collapsible app navigation.

Installation

$ pnpm dlx shadcn@latest add @esuiss/resizable

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add resizable
  1. Install the following dependencies and add the cn helper:
$ pnpm add react-resizable-panels
  1. Copy and paste the following code into your project.
components/ui/resizable.tsx
"use client"

import * as React from "react"
import * as ResizablePrimitive from "react-resizable-panels"
import { cn } from "@/lib/utils"

function animateJumps(
  group: HTMLElement | null,
  previous: ResizablePrimitive.Layout | null,
  next: ResizablePrimitive.Layout
) {
  if (!group || !previous) return
  if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return
  const jumped = Object.entries(next).some(
    ([id, size]) => Math.abs(size - (previous[id] ?? size)) > 8
  )
  1. Update the import paths to match your project setup.

Usage

import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/components/ui/resizable"
<ResizablePanelGroup orientation="horizontal">
  <ResizablePanel defaultSize="50%">
    <div className="flex h-full items-center justify-center p-6">Inbox</div>
  </ResizablePanel>
  <ResizableHandle />
  <ResizablePanel defaultSize="50%">
    <div className="flex h-full items-center justify-center p-6">Message</div>
  </ResizablePanel>
</ResizablePanelGroup>

Composition

Use the following composition to build a ResizablePanelGroup:

ResizablePanelGroup
├── ResizablePanel
└── ResizableHandle

Examples

With handle

A sidebar and content split with a minimum sidebar size. Set withHandle on ResizableHandle to show a visible grip.

import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/components/ui/resizable"

export default function ResizableWithHandle() {
  return (
    <div className="h-80 w-[36rem] overflow-hidden rounded-2xl border">
      <ResizablePanelGroup orientation="horizontal">
        <ResizablePanel defaultSize="30%" minSize="20%">
          <div className="flex h-full items-center justify-center p-6 text-sm font-medium">
            Sidebar
          </div>
        </ResizablePanel>
        <ResizableHandle withHandle />

Vertical

Set orientation="vertical" on the group to stack the panels. Resize them with the up and down arrow keys.

import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/components/ui/resizable"

export default function ResizableVertical() {
  return (
    <div className="h-80 w-[36rem] overflow-hidden rounded-2xl border">
      <ResizablePanelGroup orientation="vertical">
        <ResizablePanel defaultSize="30%" minSize="20%">
          <div className="flex h-full items-center justify-center p-6 text-sm font-medium">
            Sidebar
          </div>
        </ResizablePanel>
        <ResizableHandle withHandle />

Nested

A vertical group nested inside a horizontal group to create three panes.

import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/components/ui/resizable"

export default function ResizableNested() {
  return (
    <div className="h-80 w-[36rem] overflow-hidden rounded-2xl border">
      <ResizablePanelGroup orientation="horizontal">
        <ResizablePanel defaultSize="30%" minSize="20%">
          <div className="flex h-full items-center justify-center p-6 text-sm font-medium">
            Files
          </div>
        </ResizablePanel>
        <ResizableHandle withHandle />

Cards

Set variant="cards" to render each panel as a rounded card with a pill-shaped grip. Both panels are collapsible and report their share of the space.

import { CashRegisterIcon, CookingPotIcon } from "@phosphor-icons/react"
import * as React from "react"
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/components/ui/resizable"
import { ScrollArea } from "@/components/ui/scroll-area"

export default function ResizableCards() {
  const [layout, setLayout] = React.useState<Record<string, number>>({})

  return (
    <div className="h-80 w-[36rem]">
      <ResizablePanelGroup
        orientation="horizontal"

Cards vertical

The cards variant in a vertical orientation.

import { CashRegisterIcon, CookingPotIcon } from "@phosphor-icons/react"
import * as React from "react"
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/components/ui/resizable"
import { ScrollArea } from "@/components/ui/scroll-area"

export default function ResizableCardsVertical() {
  const [layout, setLayout] = React.useState<Record<string, number>>({})

  return (
    <div className="h-80 w-[36rem]">
      <ResizablePanelGroup
        orientation="vertical"

Accessibility

  • Each handle has the separator role with aria-valuenow and aria-orientation, and is focusable with Tab.
  • Arrow keys resize the adjacent panels; Home and End move the handle to its minimum and maximum.
  • A panel that collapses to zero width or height becomes inert, so its content leaves the tab order.

API Reference

ResizablePanelGroup

The container that arranges panels and handles and tracks the layout.

PropTypeDefault
variant"default" | "cards""default"

Also accepts the props of GroupProps from react-resizable-panels.

Set orientation to horizontal (default) or vertical. variant is default for flat panels with thin dividers, or cards for rounded panels with pill grips. Use onLayoutChange to read the current sizes, keyed by each panel's id. Large layout jumps, such as collapsing or expanding a panel, animate unless the user prefers reduced motion.

ResizablePanel

One resizable section of the layout.

Also accepts the props of PanelProps from react-resizable-panels.

Size panels with defaultSize, minSize and maxSize, for example "30%". Make a panel collapsible with a collapsedSize to let it collapse when dragged past its minimum. Collapsed panels expose data-empty.

ResizableHandle

The draggable divider between two panels.

PropTypeDefault
withHandleboolean-

Also accepts the props of SeparatorProps from react-resizable-panels.

withHandle shows a visible grip on the divider. A handle next to a collapsed panel gets data-collapsed set to start or end, and its grip appears on hover.

Each part sets a data-slot, such as resizable-panel-group, for styling. The group also exposes data-variant.

NextScreenPreviousRadio Group

On this page

  1. 01Installation
  2. 02Usage
  3. 03Composition
  4. 04Examples
    • With handle
    • Vertical
    • Nested
    • Cards
    • Cards vertical
  5. 05Accessibility
  6. 06API Reference
    • ResizablePanelGroup
    • ResizablePanel
    • ResizableHandle