Components

Resizable

Accessible resizable panel groups and layouts with keyboard support.

Loading...

Installation

CLI

npx shadcn@latest add https://exawizards.com/exabase/design/registry/resizable.json

Manual

Install the following dependencies:

npm install react-resizable-panels

Copy and paste the following code into your project.

"use client"

import * as ResizablePrimitive from "react-resizable-panels"
import { Dots6VerticalIcon } from "@exawizards/exabase-design-system-icons-react"

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

function ResizablePanelGroup({
  className,
  ...props
}: ResizablePrimitive.GroupProps) {
  return (
    <ResizablePrimitive.Group
      data-slot="resizable-panel-group"
      className={cn(
        "flex h-full w-full aria-[orientation=vertical]:flex-col",
        className
      )}
      {...props}
    />
  )
}

function ResizablePanel({ ...props }: ResizablePrimitive.PanelProps) {
  return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} />
}

function ResizableHandle({
  withHandle,
  children,
  className,
  ...props
}: ResizablePrimitive.SeparatorProps & {
  withHandle?: boolean
}) {
  return (
    <ResizablePrimitive.Separator
      data-slot="resizable-handle"
      className={cn(
        "relative flex w-px items-center justify-center bg-border outline-none after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-within:outline-hidden focus-visible:border-primary/50 focus-visible:bg-ring focus-visible:ring focus-visible:ring-ring/50 aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 aria-[orientation=horizontal]:forced-colors:border-b aria-[orientation=vertical]:forced-colors:border-r [&[aria-orientation=horizontal]>div]:rotate-90",

        className
      )}
      {...props}
    >
      {withHandle && (
        <div className="z-10 flex h-4 w-3 items-center justify-center rounded-xs border bg-background">
          <Dots6VerticalIcon className="size-2.5" />
        </div>
      )}
      {children}
    </ResizablePrimitive.Separator>
  )
}

export { ResizableHandle, ResizablePanel, ResizablePanelGroup }

Usage

import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/components/ui/resizable"
<ResizablePanelGroup direction="horizontal">
  <ResizablePanel>One</ResizablePanel>
  <ResizableHandle />
  <ResizablePanel>Two</ResizablePanel>
</ResizablePanelGroup>

Examples

Vertical

Use direction="vertical" for vertical resizing.

<ResizablePanelGroup direction="vertical">
Loading...

With Handle

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

<ResizableHandle withHandle />
Loading...

Custom Handle

Handle can be customized by passing custom JSX as children.

<ResizableHandle>
  <div className="z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border" />
</ResizableHandle>
Loading...

API

See the react-resizable-panels documentation for more information.

On this page