Display

Resizable panels

Panels side by side or stacked, sized by dragging the line between them, or from the keyboard.

Installation

npx sinaui add resizable

Examples

Side by side

Drag a line, or focus it and use the arrow keys. The catalog collapses when dragged small, or with Enter; double-click a line to reset. The layout is remembered.

<script lang="ts">
	import * as Resizable from '#lib/ui/resizable/index.js';
</script>

<div class="frame">
	<Resizable.Group persist="sinaui-reading-room">
		<Resizable.Panel defaultSize={24} minSize={16} collapsible label="Catalog">
			<div class="pane">
				<h4>Catalog</h4>
				<ul>
					<li>Book of Optics</li>
					<li>The Canon of Medicine</li>
					<li>Al-Jabr</li>
					<li>Tabula Rogeriana</li>
				</ul>
			</div>
		</Resizable.Panel>
		<Resizable.Handle label="Resize the catalog" />
		<Resizable.Panel minSize={30} label="Manuscript">
			<div class="pane">
				<h4>Book of Optics</h4>
				<p>
					Ibn al-Haytham argued that we see because light travels from objects into the eye, and
					tested it by experiment: light in a dark room, through a small hole.
				</p>
			</div>
		</Resizable.Panel>
		<Resizable.Handle label="Resize the notes" />
		<Resizable.Panel defaultSize={26} minSize={18} label="Notes">
			<div class="pane">
				<h4>Notes</h4>
				<p>Compare with the Latin translation, <i>De aspectibus</i>.</p>
			</div>
		</Resizable.Panel>
	</Resizable.Group>
</div>

<style>
	.frame {
		inline-size: 100%;
		block-size: 16rem;
		border-radius: calc(var(--ui-radius) * 1.5);
		background: var(--ui-surface);
		box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
		overflow: hidden;
	}
	.pane {
		padding: 1rem;
		font-size: 0.875rem;
		line-height: 1.55;
	}
	h4 {
		margin: 0 0 0.5rem;
		font-size: 0.9375rem;
	}
	p,
	ul {
		margin: 0;
		color: var(--ui-muted);
	}
	ul {
		display: grid;
		gap: 0.375rem;
		padding-inline-start: 1.1rem;
	}
</style>

Stacked

<script lang="ts">
	import * as Resizable from '#lib/ui/resizable/index.js';
</script>

<div class="frame">
	<Resizable.Group orientation="vertical">
		<Resizable.Panel minSize={25} label="Text">
			<div class="pane">
				<p>
					The Compendious Book on Calculation by Completion and Balancing, written by al-Khwarizmi
					in Baghdad around 820, gave algebra its name.
				</p>
			</div>
		</Resizable.Panel>
		<Resizable.Handle label="Resize the text" />
		<Resizable.Panel minSize={25} label="Commentary">
			<div class="pane">
				<p>“Completion” is al-jabr: moving a subtracted term to the other side of the equation.</p>
			</div>
		</Resizable.Panel>
	</Resizable.Group>
</div>

<style>
	.frame {
		inline-size: 100%;
		block-size: 14rem;
		border-radius: calc(var(--ui-radius) * 1.5);
		background: var(--ui-surface);
		box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
		overflow: hidden;
	}
	.pane {
		padding: 1rem;
		font-size: 0.9375rem;
		line-height: 1.7;
	}
	p {
		margin: 0;
	}
</style>

Props

Resizable.Group

PropTypeDefault
orientation'horizontal' | 'vertical''horizontal'
persiststring: a storage key

Resizable.Panel

PropTypeDefault
defaultSizenumber: percentan equal share
minSize, maxSizenumber: percent10, 100
collapsiblebooleanfalse
labelstring

Resizable.Handle

PropTypeDefault
labelstring (required): what it resizes

Keyboard

KeyDoes
Arrow keysMove the line by 5% (10% with Shift)
Home / EndThe panel before it at its smallest or largest
EnterCollapse a collapsible panel, or bring it back

Accessibility

  • Each line is a focusable separator: screen readers hear its name and the size of the panel it controls.
  • A collapsed panel is taken out of the page, so Tab never lands inside it.
  • The grab area is wider than the line it draws, and wider still on touch screens.
Introduction
Theming
Changelog
Button
Action button
Confirm button
Copy button
Hold to confirm
Split button
Calendar
Checkbox
Color picker
Combobox
Date picker
Date range picker
File drop
Form
Input
Mention input
Multi select
Number field
OTP input
Password input
Phone input
Radio cards
Radio group
Rich text editor
Search field
Segmented control
Select
Signature pad
Slider
Switch
Tag input
Upload
Wheel picker
Textarea
Time field
Toggle group
Toolbar
Alert dialog
Command palette
Context menu
Dialog
Drawer
Dropdown
Hover card
Popover
Tooltip
Announcement bar
Alert
Empty state
Meter
Progress
Rolling number
Skeleton
Spinner
Toast
Avatar
Avatar group
Badge
Card
Carousel
Chart
Chat
Code block
Data table
Folder
Kbd
Mind map
Resizable panels
Scroll area
Separator
Sortable
Table
Tag group
Virtual list
Audio player
Image
Image compare
Video
Visualizer
Breadcrumb
File tree
Menubar
Navigation menu
Pagination
Sidebar layout
Stepper
Tabs
Alarm clock
Clock
Dynamic island
Fluid orb
Hourglass
Stopwatch
Timer
AI chat
AI media
Auth
Board
Booking
Dashboard
File explorer
Messaging
Notifications
Settings
Team
Overview
Pricing
Agent chat
Calendar
Voice agent
Mail inbox
CMS
Blog
Marketing site
E-commerce
AI agents
SaaS landing page
SaaS app
Accordion
Dark theme
Light theme