cdk

package
v0.1.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 1 Imported by: 0

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:

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

type Content[C any] interface {
	Render(ctx C) widget.Widget
}

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:

type FuncContent

type FuncContent[C any] struct {
	Fn func(ctx C) widget.Widget
}

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.

func (StringContent) Render

func (s StringContent) Render(_ any) widget.Widget

Render returns a placeholder widget representing the text. The actual text rendering is delegated to the host widget's painter.

type WidgetContent

type WidgetContent struct {
	W widget.Widget
}

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).

func (WidgetContent) Render

func (w WidgetContent) Render(_ any) widget.Widget

Render returns the wrapped widget, ignoring the context.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL