Keyframery

Resizable

Panels glide to a new size on a spring, and the handle's grip stretches while you drag.

See it as an AI agent does.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/resizable

This adds components/keyframery/resizable.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.

Usage

import { Resizable, ResizableHandle, ResizablePanel } from "@/components/keyframery/resizable"

export default function Usage() {
  return (
    <Resizable>
      <ResizablePanel defaultSize={30}>Sidebar</ResizablePanel>
      <ResizableHandle />
      <ResizablePanel defaultSize={70}>Content</ResizablePanel>
    </Resizable>
  )
}

Anatomy

How the parts fit together:

Resizable
├── ResizablePanel
├── ResizableHandle
└── ResizablePanel

Examples

Two panels

Drag the handle, or focus it and use the arrow keys. minSize and maxSize are percentages.

Stacked, and nested

orientation="vertical" stacks panels. A Resizable inside a panel splits it again.

Collapsible, and remembered

A collapsible panel snaps shut when dragged below its minSize. autoSaveId keeps the layout between visits.

Motion

MoveWhat you see
SpringPanels glide to a new size on a spring after a key press; drags stay instant.
StretchThe grip stretches while you drag it.
FadeThe handle's line takes the ring colour.

Timing and springiness follow the motion style you set. To change how fast this resizable moves, pass speed:

<Resizable speed="fast">
  …
</Resizable>

"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.

Theming

Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.

VariableWhat it changesDefault
--resizable-lineResting divider--border
--resizable-activeHovered, focused or dragged divider--ring
--resizable-keyGrip surface--background, --accent in dark
--resizable-inkGrip dots--muted-foreground; --foreground while active
--resizable-radiusGrip corners5px
--resizable-grip-widthGrip short axis0.75rem
--resizable-grip-lengthGrip long axis1.5rem
--resizable-thicknessDivider thickness1px

API reference

Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK resizable reference.

Resizable

Renders a <div>, and takes its props too.

Prop

Type

ResizablePanel

Renders a <div>, and takes its props too.

Prop

Type

ResizableHandle

Renders a <div>, and takes its props too.

Prop

Type

Other parts

These take the props of the element they render, and nothing else:

  • ResizableGrip: a <span>

Keyboard

KeyWhat it does
← →Moves the focused handle.
Shift + ←Moves ten steps at a time.
HomeShrinks the panel before the handle as far as it goes.
EndGrows it as far as it goes.
EnterCollapses or restores a collapsible panel.

Accessibility

Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.

Swap the import

Already using UI SDK's resizable with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.

// Before
import { … } from "@ui-sdk/react/resizable"

// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/resizable"

Questions

How does the animated Resizable for UI SDK move?

Spring: Panels glide to a new size on a spring after a key press; drags stay instant. Stretch: The grip stretches while you drag it. Fade: The handle's line takes the ring colour.

Do I need Motion or Framer Motion for the animated Resizable?

No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.

Can I keep my own styling and only take the motion?

Yes. Import from @/components/keyframery/primitives/resizable instead. It has the same parts and props as @ui-sdk/react/resizable and adds motion only.

What happens to the Resizable when someone turns on reduced motion?

Nothing moves. State changes happen at once, or with a short fade.

All components

On this page