Resizable可调整大小

查看源码components/resizable.go

横向分栏#

捕获主指针拖动分隔器,激活仍可循环调用方持有的分栏比例。

启用 JavaScript 后可运行预览;源码和安装命令仍可直接查看。

用法
bounds := stage.Rect()
handle := tree.ID(page, "split")
resizable := components.BeginResizable(canvas, theme, handle, bounds, fraction).
    Limits(0.2, 0.8).HandleSize(12).WithHandle().ValueText(valueText)
layout := resizable.Paint("Resize editor panels")
canvas.Rounded(layout.First.Inset(ui.All(8)), 6, theme.Muted)
canvas.Rounded(layout.Second.Inset(ui.All(8)), 6, theme.CardElevated)

纵向分栏#

同一生产组件切换为上下堆叠布局。

启用 JavaScript 后可运行预览;源码和安装命令仍可直接查看。

用法
bounds := stage.Rect()
handle := tree.ID(page, "split")
layout := components.BeginResizable(canvas, theme, handle, bounds, fraction).
    Vertical().Limits(0.2, 0.8).HandleSize(12).WithHandle().
    Paint("Resize editor rows")
canvas.Rounded(layout.First.Inset(ui.All(8)), 6, theme.Muted)
canvas.Rounded(layout.Second.Inset(ui.All(8)), 6, theme.CardElevated)

禁用分隔器#

保留布局与抓手,但不允许交互。

启用 JavaScript 后可运行预览;源码和安装命令仍可直接查看。

用法
bounds := stage.Rect()
handle := tree.ID(page, "split")
layout := components.BeginResizable(canvas, theme, handle, bounds, fraction).
    Limits(0.2, 0.8).HandleSize(12).WithHandle().Disabled().
    Paint("Resize editor panels")
canvas.Rounded(layout.First.Inset(ui.All(8)), 6, theme.Muted)
canvas.Rounded(layout.Second.Inset(ui.All(8)), 6, theme.CardElevated)

安装

将组件源码复制到自己的项目,直接修改。

仓库命令
go run ./cmd/viva add --out ./components/local resizable

源码组件用法#

此预览直接调用生产 Go 组件。稳定 ID、值与打开状态仍由应用持有;组件只负责绘制并声明交互语义。

  • 标题旁的源码链接列出了全部选项与视觉决策。
  • 请使用原生命令验证系统文本、焦点、无障碍与平台集成。
  • 浏览器预览验证共享布局和场景行为,不代表原生性能。

验证边界#

示例覆盖当前 API 的代表性状态,但不表示每个桌面后端都已完成真机验证。

键盘操作

Tab 在控件间移动;Ctrl/⌘ K 搜索组件。进入预览后,键盘事件由 Go 运行时处理。