纵向内容#

目标区域滚动更新调用方偏移,点击滚动条仍可循环。

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

用法
contentSize := ui.Size{Width: viewport.Width, Height: 420}
area := components.BeginScrollArea(canvas, theme, viewport, contentSize).
    Offset(0, offset).
    VerticalScrollbar(tree.ID(page, "vertical"), "Scroll activity", "Scrolled")
geometry := area.BeginContent()
canvas.Label("Window created", geometry.Content,
    ui.TextStyle{Size: theme.Metrics.FontSizeM, Color: theme.Foreground})
area.EndContent()

双轴内容#

typed 滚动同时更新水平、垂直偏移和角落几何。

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

用法
contentSize := ui.Size{Width: viewport.Width + 180, Height: 420}
area := components.BeginScrollArea(canvas, theme, viewport, contentSize).
    Offset(offsetX, offsetY).
    VerticalScrollbar(tree.ID(page, "vertical"), "Scroll activity", "Scrolled").
    HorizontalScrollbar(tree.ID(page, "horizontal"), "Scroll columns", "Scrolled")
geometry := area.BeginContent()
canvas.Label("Window created", geometry.Content,
    ui.TextStyle{Size: theme.Metrics.FontSizeM, Color: theme.Foreground})
area.EndContent()

安装

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

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

源码组件用法#

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

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

验证边界#

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

键盘操作

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