Input Group输入框组
查看源码components/input_group.go域名输入#
前缀文本和清除按钮由生产 InputGroup 绘制。
components.PaintInputGroup(canvas, theme, bounds, components.InputGroupSnapshot{
ID: tree.ID(page, "domain"), Label: "Project domain", Value: value,
Placeholder: "project-name",
InlineStart: components.InputGroupSlot{
Kind: components.InputGroupSlotText, Text: "https://", Separated: true,
},
InlineEnd: components.InputGroupSlot{
Kind: components.InputGroupSlotButton, ID: tree.ID(page, "clear"),
Icon: clearIcon, ButtonSize: components.InputGroupButtonIconXS,
Label: "Clear domain",
},
})块级附加项#
块级说明、键帽和多行控制槽。
components.PaintInputGroup(canvas, theme, bounds, components.InputGroupSnapshot{
ID: tree.ID(page, "description"), Label: "Release description",
Value: value, Multiline: true,
BlockStart: components.InputGroupSlot{
Kind: components.InputGroupSlotText, Text: "Release description",
Separated: true,
},
BlockEnd: components.InputGroupSlot{
Kind: components.InputGroupSlotKbd, Text: "⌘↵",
},
})图标按钮与加载#
icon-xs / icon-sm 按钮切换密码可见,以及 Spinner 附加槽。
reveal := tree.ID(page, "reveal")
components.PaintInputGroup(canvas, theme, bounds, components.InputGroupSnapshot{
ID: tree.ID(page, "password"), Label: "Password", Value: value,
Secure: !revealed,
InlineEnd: components.InputGroupSlot{
Kind: components.InputGroupSlotButton, ID: reveal, Icon: eyeIcon,
ButtonSize: components.InputGroupButtonIconSM, Label: "Show password",
},
})
if canvas.Clicked(reveal) {
revealed = !revealed
}输入状态#
无效与禁用快照保留完整语义。
invalid := components.InputGroupSnapshot{
ID: tree.ID(page, "email"), Label: "Project domain", Value: value,
Invalid: true,
InlineStart: components.InputGroupSlot{
Kind: components.InputGroupSlotText, Text: "@", Separated: true,
},
InlineEnd: components.InputGroupSlot{
Kind: components.InputGroupSlotButton, ID: tree.ID(page, "invite"),
Text: "Invite", Disabled: true,
},
}
components.PaintInputGroup(canvas, theme, invalidBounds, invalid)
locked := components.InputGroupSnapshot{
ID: tree.ID(page, "locked"), Label: "Project domain",
Value: "locked", Disabled: true,
}
components.PaintInputGroup(canvas, theme, lockedBounds, locked)安装
将组件源码复制到自己的项目,直接修改。
go run ./cmd/viva add --out ./components/local input-group源码组件用法#
此预览直接调用生产 Go 组件。稳定 ID、值与打开状态仍由应用持有;组件只负责绘制并声明交互语义。
- 标题旁的源码链接列出了全部选项与视觉决策。
- 请使用原生命令验证系统文本、焦点、无障碍与平台集成。
- 浏览器预览验证共享布局和场景行为,不代表原生性能。
验证边界#
示例覆盖当前 API 的代表性状态,但不表示每个桌面后端都已完成真机验证。
键盘操作
Tab 在控件间移动;Ctrl/⌘ K 搜索组件。进入预览后,键盘事件由 Go 运行时处理。