Resizable
Panels side by side (or stacked) with handles you drag to share the space between them. The handles work from the keyboard too. Same markup and props in every style: switch the style in the header to see it change.
Horizontal
A sidebar and a main area. Drag the handle, or Tab to it and use the arrow keys. In HTML, add data-vin-resizable and include vinui.js.
Mailboxes
Inbox
Drafts
Sent
Archive
Inbox
Drag the handle to give the list more room, or Tab to it and use the arrow keys.
<div class="vin-resizable" style="width: 100%; max-width: 520px; height: 200px" data-vin-resizable>
<div class="vin-resizable__panel" id="rz-sidebar" style="--vin-size: 30" data-min="20">
<div style="padding: 16px">
<p style="margin: 0 0 8px; font-weight: 600">Mailboxes</p>
<p style="margin: 0; color: var(--vin-muted)">Inbox<br>Drafts<br>Sent<br>Archive</p>
</div>
</div>
<div class="vin-resizable__handle vin-resizable__handle--grip" role="separator" tabindex="0" aria-label="Resize mailboxes" aria-controls="rz-sidebar" aria-orientation="vertical" aria-valuenow="30" aria-valuemin="20" aria-valuemax="70"></div>
<div class="vin-resizable__panel" style="--vin-size: 70" data-min="30">
<div style="padding: 16px">
<p style="margin: 0 0 8px; font-weight: 600">Inbox</p>
<p style="margin: 0; color: var(--vin-muted)">Drag the handle to give the list more room, or Tab to it and use the arrow keys.</p>
</div>
</div>
</div>Mailboxes
Inbox
Drafts
Sent
Archive
Inbox
Drag the handle to give the list more room, or Tab to it and use the arrow keys.
import { ResizableGroup, ResizablePanel, ResizableHandle } from "@/components/vin/resizable";
export function ResizableHorizontal() {
return (
<ResizableGroup style={{ width: "100%", maxWidth: 520, height: 200 }}>
<ResizablePanel defaultSize={30} minSize={20}>
<div style={{ padding: 16 }}>
<p style={{ margin: "0 0 8px", fontWeight: 600 }}>Mailboxes</p>
<p style={{ margin: 0, color: "var(--vin-muted)" }}>Inbox<br />Drafts<br />Sent<br />Archive</p>
</div>
</ResizablePanel>
<ResizableHandle label="Resize mailboxes" withGrip />
<ResizablePanel defaultSize={70} minSize={30}>
<div style={{ padding: 16 }}>
<p style={{ margin: "0 0 8px", fontWeight: 600 }}>Inbox</p>
<p style={{ margin: 0, color: "var(--vin-muted)" }}>Drag the handle to give the list more room, or Tab to it and use the arrow keys.</p>
</div>
</ResizablePanel>
</ResizableGroup>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import ResizableGroup, { ResizablePanel, ResizableHandle } from "@/components/vin/resizable.vue";
const onLayout = (sizes: number[]) => console.log(sizes);
</script>
<template>
<ResizableGroup style="width: 100%; max-width: 520px; height: 200px" @layout="onLayout">
<ResizablePanel :default-size="30" :min-size="20">
<div style="padding: 16px">
<p style="margin: 0 0 8px; font-weight: 600">Mailboxes</p>
<p style="margin: 0; color: var(--vin-muted)">Inbox<br />Drafts<br />Sent<br />Archive</p>
</div>
</ResizablePanel>
<ResizableHandle label="Resize mailboxes" with-grip />
<ResizablePanel :default-size="70" :min-size="30">
<div style="padding: 16px">
<p style="margin: 0 0 8px; font-weight: 600">Inbox</p>
<p style="margin: 0; color: var(--vin-muted)">Drag the handle to give the list more room, or Tab to it and use the arrow keys.</p>
</div>
</ResizablePanel>
</ResizableGroup>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import ResizableGroup from "$lib/components/vin/resizable.svelte";
import ResizablePanel from "$lib/components/vin/resizable-panel.svelte";
import ResizableHandle from "$lib/components/vin/resizable-handle.svelte";
</script>
<ResizableGroup style="width: 100%; max-width: 520px; height: 200px">
<ResizablePanel defaultSize={30} minSize={20}>
<div style="padding: 16px">
<p style="margin: 0 0 8px; font-weight: 600">Mailboxes</p>
<p style="margin: 0; color: var(--vin-muted)">Inbox<br />Drafts<br />Sent<br />Archive</p>
</div>
</ResizablePanel>
<ResizableHandle label="Resize mailboxes" withGrip />
<ResizablePanel defaultSize={70} minSize={30}>
<div style="padding: 16px">
<p style="margin: 0 0 8px; font-weight: 600">Inbox</p>
<p style="margin: 0; color: var(--vin-muted)">Drag the handle to give the list more room, or Tab to it and use the arrow keys.</p>
</div>
</ResizablePanel>
</ResizableGroup>Vertical
An editor above a terminal. Up and Down move the handle; Enter folds the editor away and brings it back.
export function greet(name) {
return `Hello, ${name}!`;
}$ npm run dev Ready on http://localhost:4321
<div class="vin-resizable vin-resizable--vertical" style="width: 100%; max-width: 420px; height: 260px" data-vin-resizable>
<div class="vin-resizable__panel" id="rz-editor" style="--vin-size: 60" data-min="15">
<pre style="margin: 0; padding: 12px 16px; font: 13px/1.6 ui-monospace, monospace">export function greet(name) {
return `Hello, ${name}!`;
}</pre>
</div>
<div class="vin-resizable__handle vin-resizable__handle--grip" role="separator" tabindex="0" aria-label="Resize editor" aria-controls="rz-editor" aria-orientation="horizontal" aria-valuenow="60" aria-valuemin="15" aria-valuemax="85"></div>
<div class="vin-resizable__panel" style="--vin-size: 40" data-min="15">
<pre style="margin: 0; padding: 12px 16px; font: 13px/1.6 ui-monospace, monospace; color: var(--vin-muted)">$ npm run dev
Ready on http://localhost:4321</pre>
</div>
</div>export function greet(name) {
return `Hello, ${name}!`;
}$ npm run dev Ready on http://localhost:4321
import { ResizableGroup, ResizablePanel, ResizableHandle } from "@/components/vin/resizable";
const code = { margin: 0, padding: "12px 16px", font: "13px/1.6 ui-monospace, monospace" };
export function ResizableVertical() {
return (
<ResizableGroup orientation="vertical" style={{ width: "100%", maxWidth: 420, height: 260 }}>
<ResizablePanel defaultSize={60} minSize={15}>
<pre style={code}>{"export function greet(name) {\n return `Hello, ${name}!`;\n}"}</pre>
</ResizablePanel>
<ResizableHandle label="Resize editor" withGrip />
<ResizablePanel defaultSize={40} minSize={15}>
<pre style={{ ...code, color: "var(--vin-muted)" }}>{"$ npm run dev\nReady on http://localhost:4321"}</pre>
</ResizablePanel>
</ResizableGroup>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import ResizableGroup, { ResizablePanel, ResizableHandle } from "@/components/vin/resizable.vue";
const code = "margin: 0; padding: 12px 16px; font: 13px/1.6 ui-monospace, monospace";
const source = "export function greet(name) {\n return `Hello, ${name}!`;\n}";
const output = "$ npm run dev\nReady on http://localhost:4321";
</script>
<template>
<ResizableGroup orientation="vertical" style="width: 100%; max-width: 420px; height: 260px">
<ResizablePanel :default-size="60" :min-size="15">
<pre :style="code">{{ source }}</pre>
</ResizablePanel>
<ResizableHandle label="Resize editor" with-grip />
<ResizablePanel :default-size="40" :min-size="15">
<pre :style="code + '; color: var(--vin-muted)'">{{ output }}</pre>
</ResizablePanel>
</ResizableGroup>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import ResizableGroup from "$lib/components/vin/resizable.svelte";
import ResizablePanel from "$lib/components/vin/resizable-panel.svelte";
import ResizableHandle from "$lib/components/vin/resizable-handle.svelte";
const code = "margin: 0; padding: 12px 16px; font: 13px/1.6 ui-monospace, monospace";
</script>
<ResizableGroup orientation="vertical" style="width: 100%; max-width: 420px; height: 260px">
<ResizablePanel defaultSize={60} minSize={15}>
<pre style={code}>{"export function greet(name) {\n return `Hello, ${name}!`;\n}"}</pre>
</ResizablePanel>
<ResizableHandle label="Resize editor" withGrip />
<ResizablePanel defaultSize={40} minSize={15}>
<pre style="{code}; color: var(--vin-muted)">{"$ npm run dev\nReady on http://localhost:4321"}</pre>
</ResizablePanel>
</ResizableGroup>Nested
A group inside a panel: three areas, each with a minimum size so none disappears.
<div class="vin-resizable" style="width: 100%; max-width: 560px; height: 260px" data-vin-resizable>
<div class="vin-resizable__panel" id="rz-files" style="--vin-size: 25" data-min="15">
<div style="padding: 16px; font-weight: 600">Files</div>
</div>
<div class="vin-resizable__handle" role="separator" tabindex="0" aria-label="Resize files" aria-controls="rz-files" aria-orientation="vertical" aria-valuenow="25" aria-valuemin="15" aria-valuemax="70"></div>
<div class="vin-resizable__panel" style="--vin-size: 75" data-min="30">
<div class="vin-resizable vin-resizable--vertical" data-vin-resizable>
<div class="vin-resizable__panel" id="rz-preview" style="--vin-size: 65" data-min="20">
<div style="padding: 16px; font-weight: 600">Preview</div>
</div>
<div class="vin-resizable__handle" role="separator" tabindex="0" aria-label="Resize preview" aria-controls="rz-preview" aria-orientation="horizontal" aria-valuenow="65" aria-valuemin="20" aria-valuemax="80"></div>
<div class="vin-resizable__panel" style="--vin-size: 35" data-min="20">
<div style="padding: 16px; font-weight: 600">Console</div>
</div>
</div>
</div>
</div>import { ResizableGroup, ResizablePanel, ResizableHandle } from "@/components/vin/resizable";
export function ResizableNested() {
return (
<ResizableGroup style={{ width: "100%", maxWidth: 560, height: 260 }}>
<ResizablePanel defaultSize={25} minSize={15}>
<div style={{ padding: 16, fontWeight: 600 }}>Files</div>
</ResizablePanel>
<ResizableHandle label="Resize files" />
<ResizablePanel defaultSize={75} minSize={30}>
<ResizableGroup orientation="vertical">
<ResizablePanel defaultSize={65} minSize={20}>
<div style={{ padding: 16, fontWeight: 600 }}>Preview</div>
</ResizablePanel>
<ResizableHandle label="Resize preview" />
<ResizablePanel defaultSize={35} minSize={20}>
<div style={{ padding: 16, fontWeight: 600 }}>Console</div>
</ResizablePanel>
</ResizableGroup>
</ResizablePanel>
</ResizableGroup>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import ResizableGroup, { ResizablePanel, ResizableHandle } from "@/components/vin/resizable.vue";
</script>
<template>
<ResizableGroup style="width: 100%; max-width: 560px; height: 260px">
<ResizablePanel :default-size="25" :min-size="15">
<div style="padding: 16px; font-weight: 600">Files</div>
</ResizablePanel>
<ResizableHandle label="Resize files" />
<ResizablePanel :default-size="75" :min-size="30">
<ResizableGroup orientation="vertical">
<ResizablePanel :default-size="65" :min-size="20">
<div style="padding: 16px; font-weight: 600">Preview</div>
</ResizablePanel>
<ResizableHandle label="Resize preview" />
<ResizablePanel :default-size="35" :min-size="20">
<div style="padding: 16px; font-weight: 600">Console</div>
</ResizablePanel>
</ResizableGroup>
</ResizablePanel>
</ResizableGroup>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import ResizableGroup from "$lib/components/vin/resizable.svelte";
import ResizablePanel from "$lib/components/vin/resizable-panel.svelte";
import ResizableHandle from "$lib/components/vin/resizable-handle.svelte";
</script>
<ResizableGroup style="width: 100%; max-width: 560px; height: 260px">
<ResizablePanel defaultSize={25} minSize={15}>
<div style="padding: 16px; font-weight: 600">Files</div>
</ResizablePanel>
<ResizableHandle label="Resize files" />
<ResizablePanel defaultSize={75} minSize={30}>
<ResizableGroup orientation="vertical">
<ResizablePanel defaultSize={65} minSize={20}>
<div style="padding: 16px; font-weight: 600">Preview</div>
</ResizablePanel>
<ResizableHandle label="Resize preview" />
<ResizablePanel defaultSize={35} minSize={20}>
<div style="padding: 16px; font-weight: 600">Console</div>
</ResizablePanel>
</ResizableGroup>
</ResizablePanel>
</ResizableGroup>Installation
React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:
npx @vinish/ui add resizableimport { ResizableGroup, ResizablePanel, ResizableHandle } from "@/components/vin/resizable";import ResizableGroup, { ResizablePanel, ResizableHandle } from "@/components/vin/resizable.vue";import ResizableGroup from "$lib/components/vin/resizable.svelte";
import ResizableHandle from "$lib/components/vin/resizable-handle.svelte";
import ResizablePanel from "$lib/components/vin/resizable-panel.svelte";The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.
Plain HTML: the classes come with the style's stylesheet. This component also needs vinui.js for its keyboard and pointer behaviour.
API
From spec/resizable.json, which every framework version is tested against.
| Prop | Values | Default | In HTML |
|---|---|---|---|
orientationGroup: panels side by side, or stacked. | horizontalvertical | horizontal | vin-resizable--vertical |
onLayoutGroup: called with every panel's size (percent) after a change. | (sizes: number[]) => void | — | a vin-resize event on .vin-resizable, with detail.sizes |
defaultSizePanel: its starting size, in percent of the group. Panels without one share what is left. | number | — | style="--vin-size: 30" on .vin-resizable__panel |
minSizePanel: the smallest it can get, in percent. Enter on a handle collapses the panel before it to this size. | number | 10 | data-min="20" on .vin-resizable__panel |
labelHandle: what it resizes, for screen readers. | string | "Resize" | aria-label on .vin-resizable__handle |
withGripHandle: draw a small grip in the middle of the line. | boolean | false | vin-resizable__handle--grip |
Parts
| React, Vue, Svelte | HTML classes |
|---|---|
<ResizableGroup><ResizablePanel><ResizableHandle> | .vin-resizable.vin-resizable--vertical.vin-resizable__panel.vin-resizable__handle.vin-resizable__handle--grip |
Accessibility
- Each handle follows the WAI-ARIA window splitter pattern: role="separator" with tabindex="0", aria-valuenow (the size of the panel before it, in percent), aria-valuemin, aria-valuemax and aria-controls pointing at that panel.
- A handle between side-by-side panels has aria-orientation="vertical" and moves with Left and Right; between stacked panels it is horizontal and moves with Up and Down.
- Home and End move to the smallest and largest size; Enter collapses the panel before it to its minimum, and Enter again puts it back.
- Each handle has a name (aria-label) that says what it resizes, and a visible focus style in every style and mode.
- The grab area is wider than the 1px line, so it is easy to hit with a mouse or a finger.
Customize
Saved in this browser. Style and accent are in the header.