theme

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package theme provides global styling overrides for gomukit widgets.

Widgets ship a two-layer design-token system as CSS custom properties (--gomu-*). Semantic tokens default to host-injected variables (MCP Apps hosts deliver theme variables via hostContext.styles.variables) with built-in fallbacks. A Theme overrides those defaults: its CSS() block is emitted after the base stylesheet, so non-empty fields win the cascade.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Theme

type Theme struct {
	ColorBackground  string // page/widget background
	ColorSurface     string // cards, table header, inputs
	ColorText        string
	ColorTextMuted   string
	ColorBorder      string
	ColorPrimary     string // accent: primary buttons, focused controls, links
	ColorPrimaryText string // text on primary background
	ColorDanger      string
	ColorSuccess     string
	ColorWarning     string

	FontFamily     string
	FontFamilyMono string

	RadiusS string
	RadiusM string
	RadiusL string

	// SpaceUnit is the base spacing unit all gaps/paddings derive from
	// (default 0.25rem). Increase for a roomier layout, decrease for density.
	SpaceUnit string

	// Transparent removes the page fill and the gutter to the iframe edge, so
	// the frame itself becomes invisible: only the widget's card, with its
	// rounded corners, sits on the host UI. Card, tile, control and overlay
	// surfaces are untouched and stay opaque. Equivalent to ColorPage
	// "transparent" plus PagePad "0".
	//
	// It also requires the host to leave the iframe element unpainted (no
	// background, no border); see docs/theming.md.
	Transparent bool

	// ColorPage overrides the page fill alone, leaving cards, controls and
	// overlays on ColorBackground. Ignored when Transparent is set.
	ColorPage string

	// PagePad is the gutter between the widget and the iframe edge
	// (default 8px). Ignored when Transparent is set.
	PagePad string

	// Extra adds or overrides raw custom properties. Keys must start with
	// "--gomu-". Use it for tokens without a dedicated field.
	Extra map[string]string
}

Theme overrides gomukit design tokens. The zero value overrides nothing. All fields hold raw CSS values (e.g. "#0f62fe", "0.5rem", "ui-sans-serif, system-ui"). Empty fields keep the host-aware defaults.

func (*Theme) CSS

func (t *Theme) CSS() string

CSS renders the theme as declaration blocks (":root { … }" for document-level tokens, ".gomu-root { … }" for widget tokens), or "" when nothing is set. Entries that fail Validate are skipped; call Validate to surface them as errors.

func (*Theme) Validate

func (t *Theme) Validate() error

Validate reports invalid Extra keys and unsafe values that CSS() would silently skip.

Jump to

Keyboard shortcuts

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