Keel v0.5.1 中文 GitHub

Marker

Live example: a real Keel application compiled to WebAssembly. Interact with it here. The initial download is about 10 MB.Open full screen
Example sourceGo · Copyable

This is the complete source for the gallery example above.examples/components/marker.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("marker", "display", func() core.Widget { return el.Embed(markerGallery{}) })
}

type markerGallery struct{}

func (markerGallery) Render(cx *el.Context) el.Element {
	return el.Div().Gap(16).Child(el.Div().Row().Gap(8).Items(el.Center).Child(kit.Marker(kit.MarkerDot).Color(theme.Success).Render(cx), el.Text(demoText("Online", "在线"))), el.Div().Row().Gap(8).Items(el.Center).Child(kit.Marker(kit.MarkerSquare).Color(theme.Warning).Render(cx), el.Text(demoText("Pending", "待处理"))), el.Div().Row().Gap(8).Items(el.Center).Child(kit.Marker(kit.MarkerDiamond).Size(12).Color(theme.Info).Render(cx), el.Text(demoText("Milestone", "里程碑"))))
}

kit.Marker(kit.MarkerDiamond).Color(theme.Info).Size(12) creates pure graphic markers and supports MarkerDot, MarkerSquare, and MarkerDiamond. Default 8dp, color is read every time Render reads theme.Text; explicit Color remains fixed.

Markers do not expose semantics to Agents and have no keyboard operations. Used for legends, list items, and charts. When a readable label is required, the caller puts Text next to it. Parent container constraints limit the drawing size.

Verification: go run ./examples/components -section marker -theme dark, omit theme to see the light theme.

Message status, timeline boundaries, unread reminders, and loading lines use StatusMarker.