Resizable

并排或上下堆叠、之间带有拖动柄的面板——可拖动,也可按 WAI-ARIA 窗口分隔器的键盘操作,支持最小和最大尺寸、可折叠面板、双向绑定的尺寸以及可选的保存。

可用框架
  • Angular: 可用
  • Vue: 可用
  • React: 可用
  • React Native: 暂不可用

用法

Sidebar
Content
Console

Sidebar: 30%

导入

ts
import {
  SoneResizableGroupComponent,
  SoneResizableHandleComponent,
  SoneResizablePanelComponent,
} from "@surface-one/angular/resizable";

API 参考

SoneResizableGroupComponent组件

`sone-resizable-group` — resizable panels (shadcn/ui Resizable, spartan/ui Resizable): `sone-resizable-panel`s side by side (`direction="horizontal"`) or stacked (`vertical`), with a `sone-resizable-handle` between each pair. Sizes are percentages of the group, two-way as `[(sizes)]` (one per panel); each panel's `defaultSize`, `minSize`, `maxSize` and `collapsible` set the rest. A handle is a WAI-ARIA window splitter: drag it, or focus it and use the arrow keys, Home / End and Enter (collapse or restore a collapsible panel). Give `autoSaveId` and a `storage` (`localStorage`, or your own `getItem` / `setItem`) to keep the sizes between visits; the library never touches storage by itself.

选择器
sone-resizable-group
导出为
soneResizableGroup
输入
名称类型 默认值
directionResizableDirection"horizontal"
sizes双向

The panels' sizes in percent, two-way: `[(sizes)]`. Empty: their defaults.

readonly number[][]
autoSaveId

Keep the sizes in `storage` under this id.

string | nullnull
storage

Where `autoSaveId` keeps them — pass `localStorage`, or your own.

ResizableStorage | nullnull

SoneResizableHandleComponent组件

`sone-resizable-handle` — the window splitter between two panels (`role="separator"`, its value the size of the panel before it). `withHandle` draws a grip.

选择器
sone-resizable-handle
输入
名称类型 默认值
withHandle

Draw a grip on the handle.

booleanfalse
disabledbooleanfalse
label—$localize`:Names the splitter between two resizable panels:Resize panels`

SoneResizablePanelComponent组件

`sone-resizable-panel` — one panel; its size is a percentage of the group.

选择器
sone-resizable-panel
输入
名称类型 默认值
defaultSize

Its size before any is bound or stored (percent); left out, it shares the rest.

nullnull
minSizenumber0
maxSizenumber100
collapsible

It collapses to `collapsedSize` when dragged well past `minSize`, or on Enter.

booleanfalse
collapsedSizenumber0
idstring | nullnull