Layout
Resizable
Usage#
import { WDS_RESIZABLE } from '@wds/angular/resizable';Examples#
Default#
import { Component } from '@angular/core';
import { WdsResizableComponent, WdsResizableHandleComponent, WdsResizablePanelComponent } from '@wds/angular/resizable';
@Component({
selector: 'app-resizable-default-demo',
imports: [WdsResizableComponent, WdsResizablePanelComponent, WdsResizableHandleComponent],
template: `
<div class="mx-auto w-full max-w-lg">
<wds-resizable class="h-52 rounded-lg border border-border">
<wds-resizable-panel default-size="40">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Inbox</span>
</div>
</wds-resizable-panel>
<wds-resizable-handle indicator="grip"></wds-resizable-handle>
<wds-resizable-panel default-size="60">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Message</span>
</div>
</wds-resizable-panel>
</wds-resizable>
</div>
`,
})
export class ResizableDefaultDemo {}Horizontal#
import { Component } from '@angular/core';
import { WdsResizableComponent, WdsResizableHandleComponent, WdsResizablePanelComponent } from '@wds/angular/resizable';
@Component({
selector: 'app-resizable-horizontal-demo',
imports: [WdsResizableComponent, WdsResizablePanelComponent, WdsResizableHandleComponent],
template: `
<div class="mx-auto w-full max-w-lg">
<wds-resizable class="h-52 rounded-lg border border-border">
<wds-resizable-panel default-size="25">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Folders</span>
</div>
</wds-resizable-panel>
<wds-resizable-handle></wds-resizable-handle>
<wds-resizable-panel default-size="75">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Files</span>
</div>
</wds-resizable-panel>
</wds-resizable>
</div>
`,
})
export class ResizableHorizontalDemo {}Vertical#
orientation="vertical" stacks the panels; the divider is dragged up and down.
import { Component } from '@angular/core';
import { WdsResizableComponent, WdsResizableHandleComponent, WdsResizablePanelComponent } from '@wds/angular/resizable';
@Component({
selector: 'app-resizable-vertical-demo',
imports: [WdsResizableComponent, WdsResizablePanelComponent, WdsResizableHandleComponent],
template: `
<div class="mx-auto w-full max-w-lg">
<wds-resizable orientation="vertical" class="h-72 rounded-lg border border-border">
<wds-resizable-panel default-size="25">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Query</span>
</div>
</wds-resizable-panel>
<wds-resizable-handle></wds-resizable-handle>
<wds-resizable-panel default-size="75">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Results</span>
</div>
</wds-resizable-panel>
</wds-resizable>
</div>
`,
})
export class ResizableVerticalDemo {}Nested#
wds-resizable inside a panel splits it again, also in the other direction. indicator="grip" draws a short bar on the divider.
import { Component } from '@angular/core';
import { WdsResizableComponent, WdsResizableHandleComponent, WdsResizablePanelComponent } from '@wds/angular/resizable';
@Component({
selector: 'app-resizable-nested-demo',
imports: [WdsResizableComponent, WdsResizablePanelComponent, WdsResizableHandleComponent],
template: `
<div class="mx-auto w-full max-w-lg">
<wds-resizable class="h-72 rounded-lg border border-border">
<wds-resizable-panel default-size="50">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Map</span>
</div>
</wds-resizable-panel>
<wds-resizable-handle indicator="grip"></wds-resizable-handle>
<wds-resizable-panel default-size="50">
<wds-resizable orientation="vertical">
<wds-resizable-panel default-size="25">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Filters</span>
</div>
</wds-resizable-panel>
<wds-resizable-handle indicator="grip"></wds-resizable-handle>
<wds-resizable-panel default-size="75">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Stations</span>
</div>
</wds-resizable-panel>
</wds-resizable>
</wds-resizable-panel>
</wds-resizable>
</div>
`,
})
export class ResizableNestedDemo {}Pill indicator#
indicator="pill" draws a pill that grows on hover and turns primary while dragging.
import { Component } from '@angular/core';
import { WdsResizableComponent, WdsResizableHandleComponent, WdsResizablePanelComponent } from '@wds/angular/resizable';
@Component({
selector: 'app-resizable-pill-demo',
imports: [WdsResizableComponent, WdsResizablePanelComponent, WdsResizableHandleComponent],
template: `
<div class="mx-auto w-full max-w-lg">
<wds-resizable class="h-52 rounded-lg border border-border">
<wds-resizable-panel default-size="30">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Outline</span>
</div>
</wds-resizable-panel>
<wds-resizable-handle indicator="pill"></wds-resizable-handle>
<wds-resizable-panel default-size="70">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Document</span>
</div>
</wds-resizable-panel>
</wds-resizable>
</div>
`,
})
export class ResizablePillDemo {}Three panels#
min-size. A panel at its minimum passes the rest of the move on to the next panel.
import { Component } from '@angular/core';
import { WdsResizableComponent, WdsResizableHandleComponent, WdsResizablePanelComponent } from '@wds/angular/resizable';
@Component({
selector: 'app-resizable-three-panels-demo',
imports: [WdsResizableComponent, WdsResizablePanelComponent, WdsResizableHandleComponent],
template: `
<div class="mx-auto w-full max-w-lg">
<wds-resizable class="h-52 rounded-lg border border-border">
<wds-resizable-panel default-size="25" min-size="15">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Layers</span>
</div>
</wds-resizable-panel>
<wds-resizable-handle indicator="pill"></wds-resizable-handle>
<wds-resizable-panel default-size="50" min-size="30">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Canvas</span>
</div>
</wds-resizable-panel>
<wds-resizable-handle indicator="pill"></wds-resizable-handle>
<wds-resizable-panel default-size="25" min-size="15">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Properties</span>
</div>
</wds-resizable-panel>
</wds-resizable>
</div>
`,
})
export class ResizableThreePanelsDemo {}Collapsible#
collapsible panel dragged below half of min-size snaps to collapsed-size; Enter on the handle collapses and expands it. The panel fires wds-collapse and wds-expand and has collapse() and expand().
import { Component } from '@angular/core';
import { WdsResizableComponent, WdsResizableHandleComponent, WdsResizablePanelComponent } from '@wds/angular/resizable';
@Component({
selector: 'app-resizable-collapsible-demo',
imports: [WdsResizableComponent, WdsResizablePanelComponent, WdsResizableHandleComponent],
template: `
<div class="mx-auto w-full max-w-lg">
<wds-resizable class="h-52 rounded-lg border border-border">
<wds-resizable-panel default-size="30" min-size="20" collapsible collapsed-size="6">
<div class="flex h-full items-center justify-center p-3">
<span class="truncate text-sm font-semibold">Navigation</span>
</div>
</wds-resizable-panel>
<wds-resizable-handle indicator="grip"></wds-resizable-handle>
<wds-resizable-panel default-size="70" min-size="40">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold">Workspace</span>
</div>
</wds-resizable-panel>
</wds-resizable>
</div>
`,
})
export class ResizableCollapsibleDemo {}Size tracking#
wds-input fires on every move and wds-change once the pointer is released. layout in the detail holds the sizes keyed by the id of each panel; to restore a saved layout, pass it to default-size or setLayout().
import { Component, signal } from '@angular/core';
import { WDS_RESIZABLE } from '@wds/angular/resizable';
@Component({
selector: 'app-resizable-sizes-demo',
host: { class: 'block w-full' },
imports: [...WDS_RESIZABLE],
template: `
<div class="mx-auto w-full max-w-lg">
<wds-resizable class="h-52 rounded-lg border border-border" (wdsInput)="sizes.set($event.layout)">
<wds-resizable-panel id="list" default-size="30" min-size="20">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold tabular-nums">{{ round(sizes()['list']) }}%</span>
</div>
</wds-resizable-panel>
<wds-resizable-handle indicator="grip" />
<wds-resizable-panel id="details" default-size="70" min-size="30">
<div class="flex h-full items-center justify-center p-6">
<span class="text-sm font-semibold tabular-nums">{{ round(sizes()['details']) }}%</span>
</div>
</wds-resizable-panel>
</wds-resizable>
</div>
`,
})
export class ResizableSizesDemo {
// wdsInput fires on every move; keep the layout (such as in localStorage) on wdsChange.
protected readonly sizes = signal<Record<string, number>>({ list: 30, details: 70 });
protected readonly round = Math.round;
}API References#
wds-resizable#
wds-resizable-panel elements separated by wds-resizable-handle elements, laid out in a
row (horizontal) or a column (vertical). Sizes are percentages of the group. To split a panel again, put
another wds-resizable inside it.
The group fills its container (width and height 100%); give it or its container a height.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| orientation | WdsResizableOrientation | 'horizontal' | horizontal: panels side by side. vertical: panels stacked. |
| keyboard-step.keyboardStep | number | 10 | |
| disabled | boolean | false |
Events
| Event | Description |
|---|---|
| wds-inputCustomEvent<WdsResizableLayoutDetail> | |
| wds-changeCustomEvent<WdsResizableLayoutDetail> |
Methods
| Method | Description |
|---|---|
| setLayout(sizes: number[]) |
Slots
| Slot | Description |
|---|---|
| (default) | wds-resizable-panel and wds-resizable-handle elements. |
wds-resizable-panel#
wds-resizable. Sizes are percentages of the group; the group sets the current size from
default-size and from the handles. A collapsible panel dragged below half of min-size snaps to
collapsed-size.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| default-size.defaultSize | number | undefined | ||
| min-size.minSize | number | 0 | |
| max-size.maxSize | number | 100 | |
| collapsible | boolean | false | min-size, the panel collapses to collapsed-size. |
| collapsed-size.collapsedSize | number | 0 |
Events
| Event | Description |
|---|---|
| wds-collapseCustomEvent<void> | collapsible). |
| wds-expandCustomEvent<void> |
Methods
| Method | Description |
|---|---|
| collapse() | collapsible). |
| expand() | min-size). |
| resize(size: number) |
Slots
| Slot | Description |
|---|---|
| (default) | wds-resizable inside. |
wds-resizable-handle#
wds-resizable. Drag it, or focus it and use the arrow keys.
It is a separator that reports the size of the panel before it.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| indicator | WdsResizableHandleIndicator | 'none' | grip (a short bar) or pill (grows on hover and while dragging). |
| disabled | boolean | false | |
| label | string | '' | resizable.handle). |
CSS parts (::part)
| Part | Description |
|---|---|
| indicator | indicator). |
CSS custom properties
| Property | Description |
|---|---|
| --wds-resizable-handle-color | --wds-border). |
Accessibility#
Screen reader#
wds-resizable-handle is a focusable separator named by label (default Resize panels). Its aria-valuenow, aria-valuemin and aria-valuemax are the size of the panel before it and that panel’s limits, in percent; aria-controls points to that panel.
aria-orientation is perpendicular to the group: the handles of a horizontal group are vertical separators.
disabled on the handle or on the group) leaves the tab sequence and gets aria-disabled="true".
Keyboard support#
| Key | Function |
|---|---|
keyboard-step (10% by default). | |
collapsible). | |
collapsible. |