Documentation
¶
Overview ¶
Package cdk provides the Component Development Kit — design-system-agnostic building blocks for composite widgets.
The CDK sits between the core interfaces (widget/, event/, geometry/) and the generic widget implementations (core/). It provides:
- Content — a polymorphic content interface for user-supplied renderable content
- Headless behaviors (Phase 3): clickable, hoverable, overlay management
Content[C] Pattern ¶
Content[C] enables polymorphic content rendering where a host widget provides contextual data of type C to a user-supplied content renderer. Three built-in implementations cover common cases:
- StringContent — renders plain text via a label widget
- FuncContent — wraps a function for maximum flexibility
- WidgetContent — wraps a static widget
Phase 2 widgets (Button, TextField) do NOT use Content[C] — they are simple enough that functional options suffice. Content[C] is designed for Phase 3 composite widgets (VirtualizedList, Tabs, ComboBox, Dialog).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Content ¶
Content renders user-supplied content given a context of type C. The context provides information from the host widget (selection state, index, size constraints, etc.) so the content can adapt its rendering.
Built-in implementations:
- StringContent for plain text
- FuncContent for dynamic content via a function
- WidgetContent for a pre-built static widget
type FuncContent ¶
FuncContent wraps a function as Content. This is the most flexible option — the function receives full context from the host widget and returns a widget tree.
func (FuncContent[C]) Render ¶
func (f FuncContent[C]) Render(ctx C) widget.Widget
Render calls the wrapped function with the provided context.
type StringContent ¶
type StringContent struct {
Text string
}
StringContent renders a simple text label. Suitable for widgets where a plain string is sufficient (most common case).
StringContent ignores the context parameter since a static string does not depend on host widget state.
type WidgetContent ¶
WidgetContent wraps a pre-built static widget as Content. Useful when the content does not depend on host widget context (e.g., a fixed icon or image).