Resizable
Panels resized by the handles between them, by pointer or keyboard. In the look of the app's style.
Usage
import { Component, ViewEncapsulation } from '@angular/core';import { ScFrame, ScResizableHandle, ScResizableHandleGrip, ScResizablePanel, ScResizablePanelGroup,} from '@semantic-components/ui';
@Component({ selector: 'app-resizable-usage-demo', imports: [ ScFrame, ScResizableHandle, ScResizableHandleGrip, ScResizablePanelGroup, ScResizablePanel, ], template: ` <div scResizablePanelGroup scFrame class="max-w-sm"> <div scResizablePanel [defaultSize]="50"> <div class="flex h-[200px] items-center justify-center p-6"> <span class="font-semibold">One</span> </div> </div> <div scResizableHandle aria-label="Resize One"> <div scResizableHandleGrip></div> </div> <div scResizablePanel [defaultSize]="50"> <div scResizablePanelGroup orientation="vertical"> <div scResizablePanel [defaultSize]="25"> <div class="flex h-full items-center justify-center p-6"> <span class="font-semibold">Two</span> </div> </div> <div scResizableHandle aria-label="Resize Two"> <div scResizableHandleGrip></div> </div> <div scResizablePanel [defaultSize]="75"> <div class="flex h-full items-center justify-center p-6"> <span class="font-semibold">Three</span> </div> </div> </div> </div> </div> `, host: { class: 'flex w-full justify-center' }, encapsulation: ViewEncapsulation.None,})export class ResizableUsageDemo {}Anatomy
Every part is a directive on your element; the panels are the group's direct children, a handle between each two; the handle's name and grip are yours.
import { ScResizablePanelGroup, ScResizablePanel, ScResizableHandle, ScResizableHandleGrip,} from '@semantic-components/ui';<div scResizablePanelGroup orientation="…"> <div scResizablePanel [defaultSize]="…">…</div> <div scResizableHandle aria-label="…"> <div scResizableHandleGrip></div> </div> <div scResizablePanel>…</div></div>Accessibility
- A handle is a window splitter: a focusable separator whose value is the size of the panel before it (aria-valuenow, -min, -max), which it controls (aria-controls). Name it (aria-label).
- The arrow keys along its axis resize by 10% (mirrored right to left), Home and End to the limits, Enter shuts or opens a collapsible panel.
- The grip is only for the eye (aria-hidden).
Examples
Handle
Sidebar
Content
import { Component, ViewEncapsulation } from '@angular/core';import { ScFrame, ScResizableHandle, ScResizableHandleGrip, ScResizablePanel, ScResizablePanelGroup,} from '@semantic-components/ui';
/** A grip on the handle: a scResizableHandleGrip inside it. */Vertical
Header
Content
import { Component, ViewEncapsulation } from '@angular/core';import { ScFrame, ScResizableHandle, ScResizablePanel, ScResizablePanelGroup,} from '@semantic-components/ui';
/** orientation="vertical": stacked panels; a plain handle, no grip. */@Component({Collapsible
Sidebar
Content
import { Component, ViewEncapsulation } from '@angular/core';import { ScFrame, ScResizableHandle, ScResizableHandleGrip, ScResizablePanel, ScResizablePanelGroup,} from '@semantic-components/ui';
/** collapsible: dragged below half its minimum, or Enter on its handle, the sidebar shuts; Enter or a drag opens it again. */Remembered layout
One
Two
Three
import { Component, ViewEncapsulation, effect, signal } from '@angular/core';import { ScFrame, ScResizableHandle, ScResizableHandleGrip, ScResizablePanel, ScResizablePanelGroup,} from '@semantic-components/ui';
const KEY = 'resizable-demo-layout';RTL
واحد
اثنان
ثلاثة
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import { ScFrame, ScResizableHandle, ScResizableHandleGrip, ScResizablePanel, ScResizablePanelGroup,} from '@semantic-components/ui';API reference
Each part takes class, merged over the style (cn: a later class wins).
| Part | Selector | Description |
|---|---|---|
ScResizablePanelGroup | div[scResizablePanelGroup] | orientation ('horizontal', 'vertical'); [(layout)]: the panels' sizes in %, in order. |
ScResizablePanel | div[scResizablePanel] | defaultSize, minSize, maxSize (%); collapsible, collapsedSize; data-collapsed. A direct child of its group. |
ScResizableHandle | div[scResizableHandle] | The splitter between two panels: drag, arrows, Home, End, Enter; role="separator" with aria-valuenow / -min / -max, aria-controls. Name it. |
ScResizableHandleGrip | div[scResizableHandleGrip] | The handle's grip, in the style's look; aria-hidden. |