Skip to content

Resizable 可调整面板

允许用户通过拖拽调整容器大小的组件,支持 2D 调整、比例锁定以及面板分割。

基础用法

支持在水平或垂直方向上调整大小,也可以在多个方向上同时调整。

Basic Resizable
300px x 200px
Example

锁定比例

通过设置 lock-aspect-ratio 属性可以锁定调整时的宽高比。

demo
16:9 (300 x 169)
Example

面板分割

结合 BrResizableSplitBrResizableSplitPane 可以创建多面板分割布局。

Sidebar
Keyboard navigation supported
Main Content
Terminal / Console
Example

与表格组件集成

Resizable 组件可以轻松与表格组件集成,实现自适应宽度和高度的数据网格。

Resizable Table Card
ID
Name
Role
1John DoeDeveloper
2Jane SmithDesigner
3Mike JohnsonManager
Example

与卡片组件集成

将卡片放入可调整大小的容器中,并利用卡片内部的滚动区域来展示更多内容。

Resizable Card

Drag the handle to resize this card component.

This is a card component nested inside a resizable container. Notice how the card header stays fixed while the content area scrolls if it overflows.

You can integrate the Resizable component with almost any other UI element to create dynamic layouts.

Example

API

Resizable Props

属性名说明类型默认值
as渲染的 HTML 标签string'div'
width / v-model:width容器宽度number | string-
height / v-model:height容器高度number | string-
minWidth最小宽度number0
maxWidth最大宽度numberInfinity
minHeight最小高度number0
maxHeight最大高度numberInfinity
directions允许调整的方向('top' | 'right' | 'bottom' | 'left' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right')[]['right', 'bottom', 'bottom-right']
lockAspectRatio锁定宽高比,可传布尔值(锁定初始比例)或具体数字比例boolean | numberfalse
grid对齐网格大小,可传单数字或 [x, y] 数组number | [number, number]1
step键盘调整时的步长number10
disabled是否禁用booleanfalse

Resizable Emits

事件名说明回调参数
update:width宽度改变时触发(width: number) => void
update:height高度改变时触发(height: number) => void
resizeStart开始调整时触发(event: { width: number; height: number; direction: string }) => void
resize调整过程中触发(event: { width: number; height: number; direction: string }) => void
resizeEnd结束调整时触发(event: { width: number; height: number; direction: string }) => void

ResizableHandle Props

属性名说明类型默认值
direction手柄控制的方向(非 Split 模式使用)string-
split是否作为 Split 模式的手柄booleanfalse
withHandleSplit 模式下是否显示内置图标booleanfalse

ResizableSplit Props

基于 radix-vueSplitterGroup,透传其所有属性。

属性名说明类型默认值
direction分割方向'horizontal' | 'vertical'-

ResizableSplitPane Props

基于 radix-vueSplitterPanel,透传其所有属性。

属性名说明类型默认值
defaultSize默认尺寸百分比number-
minSize最小尺寸百分比number0
maxSize最大尺寸百分比number100