Link
Example sourceGo · Copyable
This is the complete source for the gallery example above.examples/components/link.go
Reuse the component construction and Render methods in a scaffolded project. The example’s registerSection and shared helpers are provided by the component gallery.
package main
import (
"github.com/dyike/keel/ui/core"
"github.com/dyike/keel/ui/el"
"github.com/dyike/keel/ui/kit"
"github.com/dyike/keel/ui/theme"
)
func init() {
registerSection("link", "general", func() core.Widget {
msg := demoText("Click the link, or focus with Tab and press Enter", "点击链接,或 Tab 聚焦后按回车")
return el.Embed(el.ViewFunc(func(cx *el.Context) el.Element {
return el.Div().P(24).Gap(8).Items(el.Start).Child(
kit.Link(demoText("View order details", "查看订单详情"), func() { msg = demoText("Details opened", "已打开详情") }).Render(cx),
el.Text(msg).TextColor(theme.Muted))
}))
})
}
Clickable text links.
kit.Link("View details", openDetail)
- Main color text, darkens on hover. It can be triggered with Tab focus, Enter or Space.
SetText,SetDisabled; when disabled, it becomes the secondary text color and does not respond to operations.
Agent: role link.
Verify: go run ./examples/components -section link, add -theme dark to check the dark theme.