dxui

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 33 Imported by: 0

README

dxui

A declarative desktop GUI framework for Go.

GoDoc License

Quick start · Examples · Documents

Highlights

  • Write your UI in Go. Compose immutable View descriptions with typed props and callbacks. dxui reconciles them with an internal retained tree.
  • Build without cgo. Framework and application builds support CGO_ENABLED=0.
  • Render on demand. An event- and deadline-driven loop waits when idle.
  • Compose everyday interfaces. Inputs, buttons, menus, tabs, overlays, images, and other controls share one styling and interaction model.
  • Customize the appearance. Typed theme tokens, runtime light/dark switching, borders, rounded corners, shadows, and interaction states.
  • Handle larger applications. Independent native child windows and a keyed, fixed-height virtual list for long collections.
  • Use Go-native resources. Pure-Go text and image processing, plus individually linkable Lucide icons through github.com/dxui-org/dxui/icon.

Quick start

Requirements

  • Go 1.25 or newer.
  • A native desktop environment to run GUI examples.

Run an example

From a local checkout of this repository:

go run ./examples/components

Explore the component catalog, or try a smaller application:

go run ./examples/calc
go run ./examples/login

To try the login example with software rendering:

go run ./examples/login -software

Create an application

Initialize the project:

go mod init example.com/hello-dxui
go get github.com/dxui-org/dxui

Save the following as main.go:

package main

import (
	"log"

	"github.com/dxui-org/dxui"
)

func main() {
	app := dxui.NewApp(dxui.AppOptions{
		Title: "Hello dxui", Width: 480, Height: 240,
	})
	name := ""

	root := func() dxui.View {
		return dxui.Box(dxui.BoxProps{
			Style: dxui.Style{Padding: dxui.Padding(24)},
			Gap:   12,
		},
			dxui.Label("What is your name?"),
			dxui.Input(dxui.InputProps{
				Key: "name", Value: name, Placeholder: "Your name",
				OnChange: dxui.Assign(&name),
			}),
			dxui.Label("Hello, " + name + "!"),
			dxui.TextButton(dxui.ButtonProps{OnPress: app.Close}, "Close"),
		)
	}

	if err := app.Run(root); err != nil {
		log.Fatal(err)
	}
}

Run it with go run .. To build explicitly without cgo:

# macOS / Linux
env CGO_ENABLED=0 go build .
# Windows PowerShell
$env:CGO_ENABLED = "0"
go build .

State belongs to your application. UI callbacks update it, and dxui rebuilds and reconciles the root description. Call App.Run directly from main; it blocks until the application closes. Use App.Update to schedule state changes from background goroutines.

Components

Area Components
Layout and scrolling Box, Scroll, VirtualList
Text and media Text, Label, Icon, Image, Avatar
Actions and groups Button, TextButton, ButtonGroup, InputGroup
Forms Input, Textarea, Select, Checkbox, Radio, ToggleSwitch, Slider
Navigation and overlays Tabs, Menu, Popover, Tooltip
Status Badge, ProgressBar

Most components use props-first constructors.

Examples

Run any example from the repository root with go run ./examples/<name>.

Example What it demonstrates
components Searchable component catalog, live properties, themes, and compositions
login A complete login form and input interactions
calc An interactive calculator with light/dark themes
multi_window Independent child windows, state, and lifecycle
virtual_list 100,000 fixed-height rows, keyed updates, and scrolling
icon_gallery Lucide icon names, sizes, colors, and stroke widths
layout_gallery Flex sizing, alignment, absolute positioning, and clipping
style_gallery Borders, rounded corners, shadows, opacity, and themes
text_gallery Fonts, CJK fallback, wrapping, alignment, and scaling
scroll_gallery Scrolling and scrollbars
select_gallery Selection controls and popup behavior

Contributing

Bug reports, documentation improvements, and focused contributions are welcome. For a rendering or input issue, include your OS/architecture, Go version, reproduction steps, and a minimal example.

In a POSIX-compatible shell with make installed, run:

make ci
make race # requires a host/toolchain with cgo race support

make ci checks formatting, runs vet and tests, builds the framework and public examples with cgo disabled, and invokes the tagged native lifecycle smoke test. A skipped native test is not evidence that the GUI runs on that platform.

For core tests and example compilation in PowerShell:

$env:CGO_ENABLED = "0"
go test ./...
go build ./examples/...

License

dxui is licensed under the MIT License.

Bundled dependencies and assets have their own licenses. See third-party notices for icons, fonts, and other dependencies.

Documentation

Overview

Package dxui contains the public, backend-independent API for dxui.

The current package includes the SDL3 application/window runtime, immutable view descriptions, deterministic ADR-0005 layout, backend-neutral paint commands, typed runtime themes, pure-Go text, the first semantic controls, lightweight vector icons, guarded pure-Go raster images, and controlled Input/Textarea editors with native text-input composition plumbing.

The API is pre-v1. During v0.x, incompatible corrections may be made without deprecated aliases; release notes and the public API audit record each one.

Example

Example is the compile-checked form of the README quickstart. App.Run is intentionally not called by the documentation test because it owns a native window and blocks until Close.

package main

import (
	"github.com/dxui-org/dxui"
)

func main() {
	app := dxui.NewApp(dxui.AppOptions{Title: "Login", Width: 900, Height: 680})
	username, password := "", ""
	root := func() dxui.View {
		return dxui.Box(dxui.BoxProps{
			Key: "form", Style: dxui.Style{Padding: dxui.PaddingXY(20, 12), Radius: dxui.Round(8)},
			Token: dxui.ComponentPanel, States: dxui.StateStyles{}, Pointer: dxui.PointerAuto,
			Gap: 12,
		},
			dxui.Input(dxui.InputProps{
				Key: "username", Value: username, Placeholder: "Username",
				OnChange: dxui.Assign(&username),
			}),
			dxui.Input(dxui.InputProps{
				Key: "password", Value: password, Password: true,
				OnChange: func(value string) { password = value },
			}),
			dxui.TextButton(dxui.ButtonProps{OnPress: app.Close}, "Cancel"),
		)
	}
	_ = app
	_ = root // Production code calls app.Run(root) directly from main.
}

Index

Examples

Constants

View Source
const (
	PathMove  = icondata.PathMove
	PathLine  = icondata.PathLine
	PathQuad  = icondata.PathQuad
	PathCubic = icondata.PathCubic
	PathClose = icondata.PathClose
)
View Source
const (
	ColorPrimitiveWhite              ColorToken = "primitive.white"
	ColorPrimitiveBlack              ColorToken = "primitive.black"
	ColorPrimitiveBlue               ColorToken = "primitive.blue"
	ColorPrimitiveGray               ColorToken = "primitive.gray"
	ColorSemanticSurface             ColorToken = "semantic.surface"
	ColorSemanticSurfaceHi           ColorToken = "semantic.surface.high"
	ColorSemanticText                ColorToken = "semantic.text"
	ColorSemanticAccent              ColorToken = "semantic.accent"
	ColorSemanticAccentHover         ColorToken = "semantic.accent.hover"
	ColorSemanticOnAccent            ColorToken = "semantic.on-accent"
	ColorSemanticFocusRing           ColorToken = "semantic.focus-ring"
	ColorSemanticDanger              ColorToken = "semantic.danger"
	ColorSemanticSuccess             ColorToken = "semantic.success"
	ColorSemanticInfo                ColorToken = "semantic.info"
	ColorSemanticWarn                ColorToken = "semantic.warn"
	ColorSemanticBorder              ColorToken = "semantic.border"
	ColorSemanticShadow              ColorToken = "semantic.shadow"
	ColorSemanticScrollTrack         ColorToken = "semantic.scroll-track"
	ColorSemanticScrollThumb         ColorToken = "semantic.scroll-thumb"
	ColorSemanticScrollThumbHover    ColorToken = "semantic.scroll-thumb-hover"
	ColorSemanticScrollThumbActive   ColorToken = "semantic.scroll-thumb-active"
	ColorSemanticScrollThumbDisabled ColorToken = "semantic.scroll-thumb-disabled"
	ColorSemanticSelectHover         ColorToken = "semantic.select-hover"
	ColorSemanticSelectSelected      ColorToken = "semantic.select-selected"
	ColorSemanticSelectDisabled      ColorToken = "semantic.select-disabled"
	ColorSemanticSliderTrack         ColorToken = "semantic.slider-track"
	ColorSemanticSliderFill          ColorToken = "semantic.slider-fill"
	ColorSemanticSliderThumb         ColorToken = "semantic.slider-thumb"
	ColorSemanticSliderThumbBorder   ColorToken = "semantic.slider-thumb-border"
	ColorSemanticProgressTrack       ColorToken = "semantic.progress-track"
	ColorSemanticProgressFill        ColorToken = "semantic.progress-fill"
	ColorSemanticTabsHover           ColorToken = "semantic.tabs-hover"
	ColorSemanticTabsPressed         ColorToken = "semantic.tabs-pressed"
	ColorSemanticTabsSelected        ColorToken = "semantic.tabs-selected"
	ColorSemanticTabsDisabled        ColorToken = "semantic.tabs-disabled"
	ColorSemanticTabsIndicator       ColorToken = "semantic.tabs-indicator"
	ColorSemanticMenuHover           ColorToken = "semantic.menu-hover"
	ColorSemanticMenuActive          ColorToken = "semantic.menu-active"
	ColorSemanticMenuSelected        ColorToken = "semantic.menu-selected"
	ColorSemanticMenuPressed         ColorToken = "semantic.menu-pressed"
	ColorSemanticMenuDisabled        ColorToken = "semantic.menu-disabled"

	MetricPrimitive0                      MetricToken = "primitive.0"
	MetricPrimitive1                      MetricToken = "primitive.1"
	MetricPrimitive2                      MetricToken = "primitive.2"
	MetricSemanticRadius                  MetricToken = "semantic.radius"
	MetricSemanticBorder                  MetricToken = "semantic.border-width"
	MetricSemanticShadow                  MetricToken = "semantic.shadow-blur"
	MetricSemanticTextSize                MetricToken = "semantic.text-size"
	MetricSemanticLineHeight              MetricToken = "semantic.line-height"
	MetricSemanticControlHeight           MetricToken = "semantic.control-height"
	MetricComponentButtonPaddingX         MetricToken = "component.button.padding-x"
	MetricComponentButtonPaddingY         MetricToken = "component.button.padding-y"
	MetricComponentButtonGroupBorderWidth MetricToken = "component.button-group.border-width"
	MetricComponentButtonGroupRadius      MetricToken = "component.button-group.radius"
	MetricComponentBadgePaddingX          MetricToken = "component.badge.padding-x"
	MetricComponentBadgePaddingY          MetricToken = "component.badge.padding-y"
	MetricComponentBadgeMinHeight         MetricToken = "component.badge.min-height"
	MetricComponentBadgeRadius            MetricToken = "component.badge.radius"
	MetricComponentInputPaddingX          MetricToken = "component.input.padding-x"
	MetricComponentInputPaddingY          MetricToken = "component.input.padding-y"
	MetricComponentInputGroupPaddingX     MetricToken = "component.input-group.padding-x"
	MetricComponentInputGroupGap          MetricToken = "component.input-group.gap"
	MetricComponentTextareaMinHeight      MetricToken = "component.textarea.min-height"
	MetricComponentToggleWidth            MetricToken = "component.toggle.width"
	MetricComponentToggleHeight           MetricToken = "component.toggle.height"
	MetricComponentToggleKnobInset        MetricToken = "component.toggle.knob-inset"
	MetricComponentSliderWidth            MetricToken = "component.slider.width"
	MetricComponentSliderHeight           MetricToken = "component.slider.height"
	MetricComponentSliderTrackHeight      MetricToken = "component.slider.track-height"
	MetricComponentSliderThumbSize        MetricToken = "component.slider.thumb-size"
	MetricComponentProgressBarWidth       MetricToken = "component.progress-bar.width"
	MetricComponentProgressBarHeight      MetricToken = "component.progress-bar.height"
	MetricComponentProgressBarTrackHeight MetricToken = "component.progress-bar.track-height"
	MetricComponentProgressBarRadius      MetricToken = "component.progress-bar.radius"
	MetricComponentCheckboxSize           MetricToken = "component.checkbox.size"
	MetricComponentCheckboxGap            MetricToken = "component.checkbox.gap"
	MetricComponentRadioSize              MetricToken = "component.radio.size"
	MetricComponentRadioGap               MetricToken = "component.radio.gap"
	MetricComponentIconSize               MetricToken = "component.icon.size"
	MetricComponentAvatarSize             MetricToken = "component.avatar.size"
	MetricComponentScrollThickness        MetricToken = "component.scroll.thickness"
	MetricComponentScrollMinThumb         MetricToken = "component.scroll.min-thumb"
	MetricComponentScrollInset            MetricToken = "component.scroll.inset"
	MetricComponentSelectPaddingX         MetricToken = "component.select.padding-x"
	MetricComponentSelectPaddingY         MetricToken = "component.select.padding-y"
	MetricComponentSelectItemHeight       MetricToken = "component.select.item-height"
	MetricComponentSelectMaxHeight        MetricToken = "component.select.max-height"
	MetricComponentSelectGap              MetricToken = "component.select.gap"
	MetricComponentPopoverPaddingX        MetricToken = "component.popover.padding-x"
	MetricComponentPopoverPaddingY        MetricToken = "component.popover.padding-y"
	MetricComponentPopoverGap             MetricToken = "component.popover.gap"
	MetricComponentTooltipPaddingX        MetricToken = "component.tooltip.padding-x"
	MetricComponentTooltipPaddingY        MetricToken = "component.tooltip.padding-y"
	MetricComponentTooltipGap             MetricToken = "component.tooltip.gap"
	MetricComponentTabsHeight             MetricToken = "component.tabs.height"
	MetricComponentTabsGap                MetricToken = "component.tabs.gap"
	MetricComponentTabsPaddingX           MetricToken = "component.tabs.padding-x"
	MetricComponentTabsPaddingY           MetricToken = "component.tabs.padding-y"
	MetricComponentTabsIndicator          MetricToken = "component.tabs.indicator-height"
	MetricComponentTabsIndicatorInset     MetricToken = "component.tabs.indicator-inset"
	MetricComponentMenuItemHeight         MetricToken = "component.menu.item-height"
	MetricComponentMenuGap                MetricToken = "component.menu.gap"
	MetricComponentMenuPaddingX           MetricToken = "component.menu.padding-x"
	MetricComponentMenuPaddingY           MetricToken = "component.menu.padding-y"

	ComponentPanel           ComponentToken = "panel"
	ComponentText            ComponentToken = "text"
	ComponentButton          ComponentToken = "button"
	ComponentButtonSecondary ComponentToken = "button.secondary"
	ComponentButtonDanger    ComponentToken = "button.danger"
	ComponentButtonGhost     ComponentToken = "button.ghost"
	ComponentButtonGroup     ComponentToken = "button-group"
	ComponentBadge           ComponentToken = "badge"
	ComponentInput           ComponentToken = "input"
	ComponentInputGroup      ComponentToken = "input-group"
	ComponentToggleSwitch    ComponentToken = "toggle-switch"
	ComponentSlider          ComponentToken = "slider"
	ComponentProgressBar     ComponentToken = "progress-bar"
	ComponentCheckbox        ComponentToken = "checkbox"
	ComponentRadio           ComponentToken = "radio"
	ComponentIcon            ComponentToken = "icon"
	ComponentImage           ComponentToken = "image"
	ComponentAvatar          ComponentToken = "avatar"
	ComponentScroll          ComponentToken = "scroll"
	ComponentSelect          ComponentToken = "select"
	ComponentTabs            ComponentToken = "tabs"
	ComponentMenu            ComponentToken = "menu"
	ComponentPopover         ComponentToken = "popover"
	ComponentTooltip         ComponentToken = "tooltip"
)
View Source
const (
	// MaxVirtualListItems bounds key metadata and extent arithmetic.
	MaxVirtualListItems = 10_000_000
	// MaxVirtualListOverscan bounds work retained outside the viewport.
	MaxVirtualListOverscan = 256
)
View Source
const ButtonDefault = ButtonPrimary

ButtonDefault is an alias for the zero-value Primary tone.

Variables

View Source
var (
	// ErrAppNotRunning reports an Update attempted outside App.Run.
	ErrAppNotRunning = errors.New("dxui: app is not running")
	// ErrAppClosed reports an operation submitted after shutdown was requested.
	ErrAppClosed = errors.New("dxui: app is closing")
)
View Source
var (
	// ErrWindowClosed reports an operation on a child window after close.
	ErrWindowClosed = errors.New("dxui: window is closed")
	// ErrWindowNotRunning reports child-window creation outside App.Run.
	ErrWindowNotRunning = errors.New("dxui: window runtime is not running")
)
View Source
var Color = colorTokenNamespace{
	Primitive: primitiveColorTokens{
		White: ColorPrimitivePaletteWhite, Black: ColorPrimitivePaletteBlack,
		Red50: ColorPrimitiveRed50, Red100: ColorPrimitiveRed100, Red200: ColorPrimitiveRed200, Red300: ColorPrimitiveRed300, Red400: ColorPrimitiveRed400, Red500: ColorPrimitiveRed500, Red600: ColorPrimitiveRed600, Red700: ColorPrimitiveRed700, Red800: ColorPrimitiveRed800, Red900: ColorPrimitiveRed900, Red950: ColorPrimitiveRed950,
		Orange50: ColorPrimitiveOrange50, Orange100: ColorPrimitiveOrange100, Orange200: ColorPrimitiveOrange200, Orange300: ColorPrimitiveOrange300, Orange400: ColorPrimitiveOrange400, Orange500: ColorPrimitiveOrange500, Orange600: ColorPrimitiveOrange600, Orange700: ColorPrimitiveOrange700, Orange800: ColorPrimitiveOrange800, Orange900: ColorPrimitiveOrange900, Orange950: ColorPrimitiveOrange950,
		Amber50: ColorPrimitiveAmber50, Amber100: ColorPrimitiveAmber100, Amber200: ColorPrimitiveAmber200, Amber300: ColorPrimitiveAmber300, Amber400: ColorPrimitiveAmber400, Amber500: ColorPrimitiveAmber500, Amber600: ColorPrimitiveAmber600, Amber700: ColorPrimitiveAmber700, Amber800: ColorPrimitiveAmber800, Amber900: ColorPrimitiveAmber900, Amber950: ColorPrimitiveAmber950,
		Yellow50: ColorPrimitiveYellow50, Yellow100: ColorPrimitiveYellow100, Yellow200: ColorPrimitiveYellow200, Yellow300: ColorPrimitiveYellow300, Yellow400: ColorPrimitiveYellow400, Yellow500: ColorPrimitiveYellow500, Yellow600: ColorPrimitiveYellow600, Yellow700: ColorPrimitiveYellow700, Yellow800: ColorPrimitiveYellow800, Yellow900: ColorPrimitiveYellow900, Yellow950: ColorPrimitiveYellow950,
		Lime50: ColorPrimitiveLime50, Lime100: ColorPrimitiveLime100, Lime200: ColorPrimitiveLime200, Lime300: ColorPrimitiveLime300, Lime400: ColorPrimitiveLime400, Lime500: ColorPrimitiveLime500, Lime600: ColorPrimitiveLime600, Lime700: ColorPrimitiveLime700, Lime800: ColorPrimitiveLime800, Lime900: ColorPrimitiveLime900, Lime950: ColorPrimitiveLime950,
		Green50: ColorPrimitiveGreen50, Green100: ColorPrimitiveGreen100, Green200: ColorPrimitiveGreen200, Green300: ColorPrimitiveGreen300, Green400: ColorPrimitiveGreen400, Green500: ColorPrimitiveGreen500, Green600: ColorPrimitiveGreen600, Green700: ColorPrimitiveGreen700, Green800: ColorPrimitiveGreen800, Green900: ColorPrimitiveGreen900, Green950: ColorPrimitiveGreen950,
		Emerald50: ColorPrimitiveEmerald50, Emerald100: ColorPrimitiveEmerald100, Emerald200: ColorPrimitiveEmerald200, Emerald300: ColorPrimitiveEmerald300, Emerald400: ColorPrimitiveEmerald400, Emerald500: ColorPrimitiveEmerald500, Emerald600: ColorPrimitiveEmerald600, Emerald700: ColorPrimitiveEmerald700, Emerald800: ColorPrimitiveEmerald800, Emerald900: ColorPrimitiveEmerald900, Emerald950: ColorPrimitiveEmerald950,
		Teal50: ColorPrimitiveTeal50, Teal100: ColorPrimitiveTeal100, Teal200: ColorPrimitiveTeal200, Teal300: ColorPrimitiveTeal300, Teal400: ColorPrimitiveTeal400, Teal500: ColorPrimitiveTeal500, Teal600: ColorPrimitiveTeal600, Teal700: ColorPrimitiveTeal700, Teal800: ColorPrimitiveTeal800, Teal900: ColorPrimitiveTeal900, Teal950: ColorPrimitiveTeal950,
		Cyan50: ColorPrimitiveCyan50, Cyan100: ColorPrimitiveCyan100, Cyan200: ColorPrimitiveCyan200, Cyan300: ColorPrimitiveCyan300, Cyan400: ColorPrimitiveCyan400, Cyan500: ColorPrimitiveCyan500, Cyan600: ColorPrimitiveCyan600, Cyan700: ColorPrimitiveCyan700, Cyan800: ColorPrimitiveCyan800, Cyan900: ColorPrimitiveCyan900, Cyan950: ColorPrimitiveCyan950,
		Sky50: ColorPrimitiveSky50, Sky100: ColorPrimitiveSky100, Sky200: ColorPrimitiveSky200, Sky300: ColorPrimitiveSky300, Sky400: ColorPrimitiveSky400, Sky500: ColorPrimitiveSky500, Sky600: ColorPrimitiveSky600, Sky700: ColorPrimitiveSky700, Sky800: ColorPrimitiveSky800, Sky900: ColorPrimitiveSky900, Sky950: ColorPrimitiveSky950,
		Blue50: ColorPrimitiveBlue50, Blue100: ColorPrimitiveBlue100, Blue200: ColorPrimitiveBlue200, Blue300: ColorPrimitiveBlue300, Blue400: ColorPrimitiveBlue400, Blue500: ColorPrimitiveBlue500, Blue600: ColorPrimitiveBlue600, Blue700: ColorPrimitiveBlue700, Blue800: ColorPrimitiveBlue800, Blue900: ColorPrimitiveBlue900, Blue950: ColorPrimitiveBlue950,
		Indigo50: ColorPrimitiveIndigo50, Indigo100: ColorPrimitiveIndigo100, Indigo200: ColorPrimitiveIndigo200, Indigo300: ColorPrimitiveIndigo300, Indigo400: ColorPrimitiveIndigo400, Indigo500: ColorPrimitiveIndigo500, Indigo600: ColorPrimitiveIndigo600, Indigo700: ColorPrimitiveIndigo700, Indigo800: ColorPrimitiveIndigo800, Indigo900: ColorPrimitiveIndigo900, Indigo950: ColorPrimitiveIndigo950,
		Violet50: ColorPrimitiveViolet50, Violet100: ColorPrimitiveViolet100, Violet200: ColorPrimitiveViolet200, Violet300: ColorPrimitiveViolet300, Violet400: ColorPrimitiveViolet400, Violet500: ColorPrimitiveViolet500, Violet600: ColorPrimitiveViolet600, Violet700: ColorPrimitiveViolet700, Violet800: ColorPrimitiveViolet800, Violet900: ColorPrimitiveViolet900, Violet950: ColorPrimitiveViolet950,
		Purple50: ColorPrimitivePurple50, Purple100: ColorPrimitivePurple100, Purple200: ColorPrimitivePurple200, Purple300: ColorPrimitivePurple300, Purple400: ColorPrimitivePurple400, Purple500: ColorPrimitivePurple500, Purple600: ColorPrimitivePurple600, Purple700: ColorPrimitivePurple700, Purple800: ColorPrimitivePurple800, Purple900: ColorPrimitivePurple900, Purple950: ColorPrimitivePurple950,
		Fuchsia50: ColorPrimitiveFuchsia50, Fuchsia100: ColorPrimitiveFuchsia100, Fuchsia200: ColorPrimitiveFuchsia200, Fuchsia300: ColorPrimitiveFuchsia300, Fuchsia400: ColorPrimitiveFuchsia400, Fuchsia500: ColorPrimitiveFuchsia500, Fuchsia600: ColorPrimitiveFuchsia600, Fuchsia700: ColorPrimitiveFuchsia700, Fuchsia800: ColorPrimitiveFuchsia800, Fuchsia900: ColorPrimitiveFuchsia900, Fuchsia950: ColorPrimitiveFuchsia950,
		Pink50: ColorPrimitivePink50, Pink100: ColorPrimitivePink100, Pink200: ColorPrimitivePink200, Pink300: ColorPrimitivePink300, Pink400: ColorPrimitivePink400, Pink500: ColorPrimitivePink500, Pink600: ColorPrimitivePink600, Pink700: ColorPrimitivePink700, Pink800: ColorPrimitivePink800, Pink900: ColorPrimitivePink900, Pink950: ColorPrimitivePink950,
		Rose50: ColorPrimitiveRose50, Rose100: ColorPrimitiveRose100, Rose200: ColorPrimitiveRose200, Rose300: ColorPrimitiveRose300, Rose400: ColorPrimitiveRose400, Rose500: ColorPrimitiveRose500, Rose600: ColorPrimitiveRose600, Rose700: ColorPrimitiveRose700, Rose800: ColorPrimitiveRose800, Rose900: ColorPrimitiveRose900, Rose950: ColorPrimitiveRose950,
		Slate50: ColorPrimitiveSlate50, Slate100: ColorPrimitiveSlate100, Slate200: ColorPrimitiveSlate200, Slate300: ColorPrimitiveSlate300, Slate400: ColorPrimitiveSlate400, Slate500: ColorPrimitiveSlate500, Slate600: ColorPrimitiveSlate600, Slate700: ColorPrimitiveSlate700, Slate800: ColorPrimitiveSlate800, Slate900: ColorPrimitiveSlate900, Slate950: ColorPrimitiveSlate950,
		Gray50: ColorPrimitiveGray50, Gray100: ColorPrimitiveGray100, Gray200: ColorPrimitiveGray200, Gray300: ColorPrimitiveGray300, Gray400: ColorPrimitiveGray400, Gray500: ColorPrimitiveGray500, Gray600: ColorPrimitiveGray600, Gray700: ColorPrimitiveGray700, Gray800: ColorPrimitiveGray800, Gray900: ColorPrimitiveGray900, Gray950: ColorPrimitiveGray950,
		Zinc50: ColorPrimitiveZinc50, Zinc100: ColorPrimitiveZinc100, Zinc200: ColorPrimitiveZinc200, Zinc300: ColorPrimitiveZinc300, Zinc400: ColorPrimitiveZinc400, Zinc500: ColorPrimitiveZinc500, Zinc600: ColorPrimitiveZinc600, Zinc700: ColorPrimitiveZinc700, Zinc800: ColorPrimitiveZinc800, Zinc900: ColorPrimitiveZinc900, Zinc950: ColorPrimitiveZinc950,
		Neutral50: ColorPrimitiveNeutral50, Neutral100: ColorPrimitiveNeutral100, Neutral200: ColorPrimitiveNeutral200, Neutral300: ColorPrimitiveNeutral300, Neutral400: ColorPrimitiveNeutral400, Neutral500: ColorPrimitiveNeutral500, Neutral600: ColorPrimitiveNeutral600, Neutral700: ColorPrimitiveNeutral700, Neutral800: ColorPrimitiveNeutral800, Neutral900: ColorPrimitiveNeutral900, Neutral950: ColorPrimitiveNeutral950,
		Stone50: ColorPrimitiveStone50, Stone100: ColorPrimitiveStone100, Stone200: ColorPrimitiveStone200, Stone300: ColorPrimitiveStone300, Stone400: ColorPrimitiveStone400, Stone500: ColorPrimitiveStone500, Stone600: ColorPrimitiveStone600, Stone700: ColorPrimitiveStone700, Stone800: ColorPrimitiveStone800, Stone900: ColorPrimitiveStone900, Stone950: ColorPrimitiveStone950,
		Taupe50: ColorPrimitiveTaupe50, Taupe100: ColorPrimitiveTaupe100, Taupe200: ColorPrimitiveTaupe200, Taupe300: ColorPrimitiveTaupe300, Taupe400: ColorPrimitiveTaupe400, Taupe500: ColorPrimitiveTaupe500, Taupe600: ColorPrimitiveTaupe600, Taupe700: ColorPrimitiveTaupe700, Taupe800: ColorPrimitiveTaupe800, Taupe900: ColorPrimitiveTaupe900, Taupe950: ColorPrimitiveTaupe950,
		Mauve50: ColorPrimitiveMauve50, Mauve100: ColorPrimitiveMauve100, Mauve200: ColorPrimitiveMauve200, Mauve300: ColorPrimitiveMauve300, Mauve400: ColorPrimitiveMauve400, Mauve500: ColorPrimitiveMauve500, Mauve600: ColorPrimitiveMauve600, Mauve700: ColorPrimitiveMauve700, Mauve800: ColorPrimitiveMauve800, Mauve900: ColorPrimitiveMauve900, Mauve950: ColorPrimitiveMauve950,
		Mist50: ColorPrimitiveMist50, Mist100: ColorPrimitiveMist100, Mist200: ColorPrimitiveMist200, Mist300: ColorPrimitiveMist300, Mist400: ColorPrimitiveMist400, Mist500: ColorPrimitiveMist500, Mist600: ColorPrimitiveMist600, Mist700: ColorPrimitiveMist700, Mist800: ColorPrimitiveMist800, Mist900: ColorPrimitiveMist900, Mist950: ColorPrimitiveMist950,
		Olive50: ColorPrimitiveOlive50, Olive100: ColorPrimitiveOlive100, Olive200: ColorPrimitiveOlive200, Olive300: ColorPrimitiveOlive300, Olive400: ColorPrimitiveOlive400, Olive500: ColorPrimitiveOlive500, Olive600: ColorPrimitiveOlive600, Olive700: ColorPrimitiveOlive700, Olive800: ColorPrimitiveOlive800, Olive900: ColorPrimitiveOlive900, Olive950: ColorPrimitiveOlive950,
	},
	Semantic: semanticColorTokens{
		Surface: ColorSemanticSurface, SurfaceHigh: ColorSemanticSurfaceHi,
		Text: ColorSemanticText, Accent: ColorSemanticAccent,
		AccentHover: ColorSemanticAccentHover, Danger: ColorSemanticDanger,
		OnAccent: ColorSemanticOnAccent, FocusRing: ColorSemanticFocusRing,
		Success: ColorSemanticSuccess, Info: ColorSemanticInfo, Warn: ColorSemanticWarn,
		Border: ColorSemanticBorder, Shadow: ColorSemanticShadow,
	},
}

Color is the public color-token namespace.

Functions

func Assign

func Assign[T any](target *T) func(T)

Assign returns a callback that stores its argument in target. It is intended for simple controlled UI callbacks. Assign panics when target is nil; it does not schedule work or replace App.Update for cross-goroutine mutation.

Types

type Align

type Align uint8

Align controls cross-axis alignment.

const (
	AlignStart Align = iota
	AlignCenter
	AlignEnd
	AlignStretch
)

type App

type App struct {
	// contains filtered or unexported fields
}

App owns one application runtime, one main window and any child windows. An App is single-use: Run may be called exactly once.

func NewApp

func NewApp(options AppOptions) *App

NewApp creates an application configuration without loading SDL.

func (*App) Close

func (a *App) Close()

Close requests application shutdown and safely wakes a blocked event wait. It may be called from callbacks or any goroutine. Repeated calls and calls made before Run are no-ops.

func (*App) CreateWindow

func (a *App) CreateWindow(options WindowOptions, root func() View) (*Window, error)

CreateWindow creates a hidden native child window and prepares its complete first frame. It must be called from a UI callback or App.Update closure. Failure releases every partially created child resource and leaves existing windows unchanged.

func (*App) Diagnostics

func (a *App) Diagnostics() RuntimeDiagnostics

Diagnostics returns a race-safe, SDL-free runtime snapshot.

func (*App) Invalidate

func (a *App) Invalidate() error

Invalidate requests a rebuild of the main window only. It is safe from any goroutine; child windows use Window.Invalidate.

func (*App) IsMaximized

func (a *App) IsMaximized() bool

func (*App) IsMinimized

func (a *App) IsMinimized() bool

func (*App) Maximize

func (a *App) Maximize() error

func (*App) Minimize

func (a *App) Minimize() error

func (*App) Run

func (a *App) Run(root func() View) (runErr error)

Run creates the native window, builds root, and owns the process main thread until the app closes. Call it directly from main, before moving UI work to other goroutines. Run is blocking and may be called only once, including after a startup or runtime error. A nil root is rejected before the App is consumed. Startup, build, renderer, callback, and event-loop failures are returned; OnError also observes runtime failures when configured.

func (*App) RunResponsive

func (a *App) RunResponsive(root func(LayoutContext) View) error

RunResponsive is Run with a root builder that may choose a different view structure from the current logical window size. Measuring a result never invokes the builder again; only a later coalesced viewport event can do so.

func (*App) SetClipboardText

func (a *App) SetClipboardText(value string) error

SetClipboardText writes UTF-8 text to the system clipboard. While Run is active, call it from a UI callback or inside Update so the native operation remains on the UI thread. Invalid UTF-8 is normalized to replacement runes.

func (*App) SetSize

func (a *App) SetSize(width, height float32) error

func (*App) SetTheme

func (a *App) SetTheme(source Theme) error

SetTheme validates and copies a complete Primitive -> Semantic -> Component theme atomically. Equal themes are a no-op. A relevant metric-token change schedules layout; visual-only resolved changes schedule display/paint only. While Run is active, call SetTheme from a UI callback or inside Update.

func (*App) SetTitle

func (a *App) SetTitle(title string) error

func (*App) Size

func (a *App) Size() Size

func (*App) Title

func (a *App) Title() string

Main-window counterparts preserve App as the main lifecycle handle.

func (*App) Unmaximize

func (a *App) Unmaximize() error

func (*App) Unminimize

func (a *App) Unminimize() error

func (*App) Update

func (a *App) Update(update func()) error

Update queues a state update for FIFO execution on the UI thread, then rebuilds the root once after the batch. It never executes update on the caller's goroutine and is safe to call from any goroutine.

type AppOptions

type AppOptions struct {
	Title               string
	Width, Height       float32
	MinWidth, MinHeight float32
	Renderer            RendererPreference
	Background          RGBAColor
	Caches              CacheBudgets
	Fonts               []Font
	DefaultFont         FontFamily
	// DisableSystemFontFallback prevents lazy deterministic system-CJK font
	// loading. The zero value enables fallback after all application fonts and
	// dxui's built-in Latin font.
	DisableSystemFontFallback bool
	Theme                     Theme
	Shortcuts                 []Shortcut
	// OnCloseRequest handles a native window-close request on the UI thread.
	// A nil callback closes the App. A non-nil callback must call Close when it
	// accepts the request.
	OnCloseRequest func(*App)
	// OnError observes recoverable build and callback failures on the UI
	// thread. When nil, the failure terminates Run and is returned.
	OnError func(error)
	// OnShown runs once on the UI thread after the complete first frame was
	// presented and the native window was shown successfully. It is not called
	// after startup failure or on later builds/presents.
	OnShown func(*App)
	// Diagnostics enables bounded event/timing/resource counters.
	// It is false by default so release event and render paths avoid the work.
	Diagnostics bool
}

AppOptions configures an App's main window and shared runtime. Its zero value selects documented window, renderer, cache, font, and theme defaults; invalid dimensions, renderer values, fonts, or themes are reported by App.Run before native event processing begins.

type AvatarProps

type AvatarProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior
	Source  ImageSource
	Shape   AvatarShape
	Size    float32
	// OnLoad and OnError are optional notifications; nil does not stop decoding.
	OnLoad  func(Size)
	OnError func(error)
}

AvatarProps configures a square, centered cover image. Size is measured in logical units; zero uses the current component theme default. Explicit Style width and height take precedence.

type AvatarShape

type AvatarShape uint8

AvatarShape selects the fixed Avatar clipping shape.

const (
	AvatarCircle AvatarShape = iota
	AvatarSquare
)

type BadgeProps

type BadgeProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior
}

BadgeProps configures a compact, non-interactive label around one arbitrary child. The child inherits the Badge text/icon tint unless locally overridden.

type Border

type Border struct {
	Width   MetricValue
	Color   ColorValue
	Pattern BorderPattern
	// Sides defaults to all edges. In Style, a Width/Color assignment resets
	// Sides too; otherwise nonzero Sides changes only edge selection.
	// StylePatch.Border replaces the complete Border.
	Sides BorderSides
}

Border is a paint-only border drawn inside a view's layout bounds. Each side owns the nearest half of its two adjacent corner arcs.

Example
package main

import (
	"github.com/dxui-org/dxui"
)

func main() {
	_ = dxui.Border{Width: dxui.Metric(1), Color: dxui.TokenColor(dxui.ColorSemanticBorder), Sides: dxui.BorderBottom}
	_ = dxui.Border{Width: dxui.Metric(1), Color: dxui.TokenColor(dxui.ColorSemanticBorder), Sides: dxui.BorderLeft | dxui.BorderRight}
}

func NoBorder

func NoBorder() Border

NoBorder explicitly clears the border width. In ordinary Style, later state patches may restore a border; Style.Force is applied after those patches.

Example
package main

import (
	"github.com/dxui-org/dxui"
)

func main() {
	_ = dxui.Style{Border: dxui.NoBorder()}
	_ = dxui.StylePatch{Border: dxui.Some(dxui.NoBorder())}
	// Force applies after active interaction states.
	_ = dxui.Style{Force: dxui.StylePatch{Border: dxui.Some(dxui.NoBorder())}}
}

func Stroke

func Stroke(width float32, color ColorValue) Border

Stroke creates a solid border with a literal logical-unit width.

type BorderPattern

type BorderPattern uint8

BorderPattern selects how a border is painted. The zero value is solid.

const (
	BorderSolid BorderPattern = iota
	BorderDashed
)

type BorderSides

type BorderSides uint8

BorderSides selects edges. Zero means all edges, not an absent border.

const (
	BorderTop BorderSides = 1 << iota
	BorderRight
	BorderBottom
	BorderLeft
	BorderAll = BorderTop | BorderRight | BorderBottom | BorderLeft
)

type BoxProps

type BoxProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior

	Direction Direction
	Gap       float32
	Justify   Justify
	Align     Align
}

BoxProps configures a Box. Gap is a fixed logical-unit spacing; zero means no spacing between children.

type ButtonGroupOrientation

type ButtonGroupOrientation uint8

ButtonGroupOrientation selects the main axis used to arrange buttons.

const (
	ButtonGroupHorizontal ButtonGroupOrientation = iota
	ButtonGroupVertical
)

type ButtonGroupProps

type ButtonGroupProps struct {
	Key         string
	Style       Style
	Token       ComponentToken
	States      StateStyles
	Pointer     PointerBehavior
	Orientation ButtonGroupOrientation
	// Dividers enables one themed border between adjacent Buttons.
	Dividers bool
}

ButtonGroupProps configures a non-focusable connected container of Button views.

type ButtonProps

type ButtonProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior
	Variant ButtonVariant
	Tone    ButtonTone
	Size    ButtonSize
	// Disabled removes focus and activation and suppresses Hover, Pressed, and Focus styles.
	Disabled bool
	// OnPress runs on activation. Nil preserves focus and interaction visuals but emits no action.
	OnPress func()
}

ButtonProps configures a semantic button.

type ButtonSize

type ButtonSize uint8

ButtonSize selects overridable padding, minimum height, and inherited text metrics.

const (
	ButtonNormal ButtonSize = iota
	ButtonSmall
	ButtonLarge
)

type ButtonTone

type ButtonTone uint8

ButtonTone selects semantic colors independently of the surface recipe.

const (
	ButtonPrimary ButtonTone = iota
	ButtonSecondary
	ButtonSuccess
	ButtonInfo
	ButtonWarn
	ButtonDanger
)

type ButtonVariant

type ButtonVariant uint8

ButtonVariant selects a Button's surface and border recipe.

const (
	ButtonFilled ButtonVariant = iota // Filled is the compatible default.
	ButtonSoft
	ButtonOutline
	ButtonDashed
	ButtonGhost
	ButtonLink // Link is an action, with compact spacing; it never navigates.
)

type CacheBudgets

type CacheBudgets struct {
	FontBytes        int
	TextSourceBytes  int
	GlyphBytes       int
	TextMeasureBytes int
	ImageBytes       int
	ShadowBytes      int
}

CacheBudgets bounds CPU and renderer-owned text, icon, and image resources. Zero selects defaults: FontBytes 32 MiB, TextSourceBytes 2 MiB, GlyphBytes 2 MiB, TextMeasureBytes 1 MiB, ImageBytes 2 MiB, and ShadowBytes 2 MiB. ImageBytes bounds inactive reusable CPU pixels and renderer textures. Unique images in the committed display are working-set resources charged at four bytes per source pixel until that display releases them. A negative cache budget disables that cache; negative FontBytes or TextSourceBytes permits no application fonts or retained text/icon masks respectively.

type CheckboxProps

type CheckboxProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior
	// Checked is authoritative. Disabled cancels interaction and removes the focus stop.
	Checked, Disabled bool
	// OnChange proposes Checked. Nil preserves focus/press visuals without changing Checked.
	OnChange func(bool)
}

CheckboxProps configures a controlled two-state checkbox.

type ColorToken

type ColorToken string

ColorToken names a theme color.

const (
	ColorPrimitivePaletteWhite ColorToken = "primitive.palette.white"
	ColorPrimitivePaletteBlack ColorToken = "primitive.palette.black"
	ColorPrimitiveRed50        ColorToken = "primitive.red.50"
	ColorPrimitiveRed100       ColorToken = "primitive.red.100"
	ColorPrimitiveRed200       ColorToken = "primitive.red.200"
	ColorPrimitiveRed300       ColorToken = "primitive.red.300"
	ColorPrimitiveRed400       ColorToken = "primitive.red.400"
	ColorPrimitiveRed500       ColorToken = "primitive.red.500"
	ColorPrimitiveRed600       ColorToken = "primitive.red.600"
	ColorPrimitiveRed700       ColorToken = "primitive.red.700"
	ColorPrimitiveRed800       ColorToken = "primitive.red.800"
	ColorPrimitiveRed900       ColorToken = "primitive.red.900"
	ColorPrimitiveRed950       ColorToken = "primitive.red.950"
	ColorPrimitiveOrange50     ColorToken = "primitive.orange.50"
	ColorPrimitiveOrange100    ColorToken = "primitive.orange.100"
	ColorPrimitiveOrange200    ColorToken = "primitive.orange.200"
	ColorPrimitiveOrange300    ColorToken = "primitive.orange.300"
	ColorPrimitiveOrange400    ColorToken = "primitive.orange.400"
	ColorPrimitiveOrange500    ColorToken = "primitive.orange.500"
	ColorPrimitiveOrange600    ColorToken = "primitive.orange.600"
	ColorPrimitiveOrange700    ColorToken = "primitive.orange.700"
	ColorPrimitiveOrange800    ColorToken = "primitive.orange.800"
	ColorPrimitiveOrange900    ColorToken = "primitive.orange.900"
	ColorPrimitiveOrange950    ColorToken = "primitive.orange.950"
	ColorPrimitiveAmber50      ColorToken = "primitive.amber.50"
	ColorPrimitiveAmber100     ColorToken = "primitive.amber.100"
	ColorPrimitiveAmber200     ColorToken = "primitive.amber.200"
	ColorPrimitiveAmber300     ColorToken = "primitive.amber.300"
	ColorPrimitiveAmber400     ColorToken = "primitive.amber.400"
	ColorPrimitiveAmber500     ColorToken = "primitive.amber.500"
	ColorPrimitiveAmber600     ColorToken = "primitive.amber.600"
	ColorPrimitiveAmber700     ColorToken = "primitive.amber.700"
	ColorPrimitiveAmber800     ColorToken = "primitive.amber.800"
	ColorPrimitiveAmber900     ColorToken = "primitive.amber.900"
	ColorPrimitiveAmber950     ColorToken = "primitive.amber.950"
	ColorPrimitiveYellow50     ColorToken = "primitive.yellow.50"
	ColorPrimitiveYellow100    ColorToken = "primitive.yellow.100"
	ColorPrimitiveYellow200    ColorToken = "primitive.yellow.200"
	ColorPrimitiveYellow300    ColorToken = "primitive.yellow.300"
	ColorPrimitiveYellow400    ColorToken = "primitive.yellow.400"
	ColorPrimitiveYellow500    ColorToken = "primitive.yellow.500"
	ColorPrimitiveYellow600    ColorToken = "primitive.yellow.600"
	ColorPrimitiveYellow700    ColorToken = "primitive.yellow.700"
	ColorPrimitiveYellow800    ColorToken = "primitive.yellow.800"
	ColorPrimitiveYellow900    ColorToken = "primitive.yellow.900"
	ColorPrimitiveYellow950    ColorToken = "primitive.yellow.950"
	ColorPrimitiveLime50       ColorToken = "primitive.lime.50"
	ColorPrimitiveLime100      ColorToken = "primitive.lime.100"
	ColorPrimitiveLime200      ColorToken = "primitive.lime.200"
	ColorPrimitiveLime300      ColorToken = "primitive.lime.300"
	ColorPrimitiveLime400      ColorToken = "primitive.lime.400"
	ColorPrimitiveLime500      ColorToken = "primitive.lime.500"
	ColorPrimitiveLime600      ColorToken = "primitive.lime.600"
	ColorPrimitiveLime700      ColorToken = "primitive.lime.700"
	ColorPrimitiveLime800      ColorToken = "primitive.lime.800"
	ColorPrimitiveLime900      ColorToken = "primitive.lime.900"
	ColorPrimitiveLime950      ColorToken = "primitive.lime.950"
	ColorPrimitiveGreen50      ColorToken = "primitive.green.50"
	ColorPrimitiveGreen100     ColorToken = "primitive.green.100"
	ColorPrimitiveGreen200     ColorToken = "primitive.green.200"
	ColorPrimitiveGreen300     ColorToken = "primitive.green.300"
	ColorPrimitiveGreen400     ColorToken = "primitive.green.400"
	ColorPrimitiveGreen500     ColorToken = "primitive.green.500"
	ColorPrimitiveGreen600     ColorToken = "primitive.green.600"
	ColorPrimitiveGreen700     ColorToken = "primitive.green.700"
	ColorPrimitiveGreen800     ColorToken = "primitive.green.800"
	ColorPrimitiveGreen900     ColorToken = "primitive.green.900"
	ColorPrimitiveGreen950     ColorToken = "primitive.green.950"
	ColorPrimitiveEmerald50    ColorToken = "primitive.emerald.50"
	ColorPrimitiveEmerald100   ColorToken = "primitive.emerald.100"
	ColorPrimitiveEmerald200   ColorToken = "primitive.emerald.200"
	ColorPrimitiveEmerald300   ColorToken = "primitive.emerald.300"
	ColorPrimitiveEmerald400   ColorToken = "primitive.emerald.400"
	ColorPrimitiveEmerald500   ColorToken = "primitive.emerald.500"
	ColorPrimitiveEmerald600   ColorToken = "primitive.emerald.600"
	ColorPrimitiveEmerald700   ColorToken = "primitive.emerald.700"
	ColorPrimitiveEmerald800   ColorToken = "primitive.emerald.800"
	ColorPrimitiveEmerald900   ColorToken = "primitive.emerald.900"
	ColorPrimitiveEmerald950   ColorToken = "primitive.emerald.950"
	ColorPrimitiveTeal50       ColorToken = "primitive.teal.50"
	ColorPrimitiveTeal100      ColorToken = "primitive.teal.100"
	ColorPrimitiveTeal200      ColorToken = "primitive.teal.200"
	ColorPrimitiveTeal300      ColorToken = "primitive.teal.300"
	ColorPrimitiveTeal400      ColorToken = "primitive.teal.400"
	ColorPrimitiveTeal500      ColorToken = "primitive.teal.500"
	ColorPrimitiveTeal600      ColorToken = "primitive.teal.600"
	ColorPrimitiveTeal700      ColorToken = "primitive.teal.700"
	ColorPrimitiveTeal800      ColorToken = "primitive.teal.800"
	ColorPrimitiveTeal900      ColorToken = "primitive.teal.900"
	ColorPrimitiveTeal950      ColorToken = "primitive.teal.950"
	ColorPrimitiveCyan50       ColorToken = "primitive.cyan.50"
	ColorPrimitiveCyan100      ColorToken = "primitive.cyan.100"
	ColorPrimitiveCyan200      ColorToken = "primitive.cyan.200"
	ColorPrimitiveCyan300      ColorToken = "primitive.cyan.300"
	ColorPrimitiveCyan400      ColorToken = "primitive.cyan.400"
	ColorPrimitiveCyan500      ColorToken = "primitive.cyan.500"
	ColorPrimitiveCyan600      ColorToken = "primitive.cyan.600"
	ColorPrimitiveCyan700      ColorToken = "primitive.cyan.700"
	ColorPrimitiveCyan800      ColorToken = "primitive.cyan.800"
	ColorPrimitiveCyan900      ColorToken = "primitive.cyan.900"
	ColorPrimitiveCyan950      ColorToken = "primitive.cyan.950"
	ColorPrimitiveSky50        ColorToken = "primitive.sky.50"
	ColorPrimitiveSky100       ColorToken = "primitive.sky.100"
	ColorPrimitiveSky200       ColorToken = "primitive.sky.200"
	ColorPrimitiveSky300       ColorToken = "primitive.sky.300"
	ColorPrimitiveSky400       ColorToken = "primitive.sky.400"
	ColorPrimitiveSky500       ColorToken = "primitive.sky.500"
	ColorPrimitiveSky600       ColorToken = "primitive.sky.600"
	ColorPrimitiveSky700       ColorToken = "primitive.sky.700"
	ColorPrimitiveSky800       ColorToken = "primitive.sky.800"
	ColorPrimitiveSky900       ColorToken = "primitive.sky.900"
	ColorPrimitiveSky950       ColorToken = "primitive.sky.950"
	ColorPrimitiveBlue50       ColorToken = "primitive.blue.50"
	ColorPrimitiveBlue100      ColorToken = "primitive.blue.100"
	ColorPrimitiveBlue200      ColorToken = "primitive.blue.200"
	ColorPrimitiveBlue300      ColorToken = "primitive.blue.300"
	ColorPrimitiveBlue400      ColorToken = "primitive.blue.400"
	ColorPrimitiveBlue500      ColorToken = "primitive.blue.500"
	ColorPrimitiveBlue600      ColorToken = "primitive.blue.600"
	ColorPrimitiveBlue700      ColorToken = "primitive.blue.700"
	ColorPrimitiveBlue800      ColorToken = "primitive.blue.800"
	ColorPrimitiveBlue900      ColorToken = "primitive.blue.900"
	ColorPrimitiveBlue950      ColorToken = "primitive.blue.950"
	ColorPrimitiveIndigo50     ColorToken = "primitive.indigo.50"
	ColorPrimitiveIndigo100    ColorToken = "primitive.indigo.100"
	ColorPrimitiveIndigo200    ColorToken = "primitive.indigo.200"
	ColorPrimitiveIndigo300    ColorToken = "primitive.indigo.300"
	ColorPrimitiveIndigo400    ColorToken = "primitive.indigo.400"
	ColorPrimitiveIndigo500    ColorToken = "primitive.indigo.500"
	ColorPrimitiveIndigo600    ColorToken = "primitive.indigo.600"
	ColorPrimitiveIndigo700    ColorToken = "primitive.indigo.700"
	ColorPrimitiveIndigo800    ColorToken = "primitive.indigo.800"
	ColorPrimitiveIndigo900    ColorToken = "primitive.indigo.900"
	ColorPrimitiveIndigo950    ColorToken = "primitive.indigo.950"
	ColorPrimitiveViolet50     ColorToken = "primitive.violet.50"
	ColorPrimitiveViolet100    ColorToken = "primitive.violet.100"
	ColorPrimitiveViolet200    ColorToken = "primitive.violet.200"
	ColorPrimitiveViolet300    ColorToken = "primitive.violet.300"
	ColorPrimitiveViolet400    ColorToken = "primitive.violet.400"
	ColorPrimitiveViolet500    ColorToken = "primitive.violet.500"
	ColorPrimitiveViolet600    ColorToken = "primitive.violet.600"
	ColorPrimitiveViolet700    ColorToken = "primitive.violet.700"
	ColorPrimitiveViolet800    ColorToken = "primitive.violet.800"
	ColorPrimitiveViolet900    ColorToken = "primitive.violet.900"
	ColorPrimitiveViolet950    ColorToken = "primitive.violet.950"
	ColorPrimitivePurple50     ColorToken = "primitive.purple.50"
	ColorPrimitivePurple100    ColorToken = "primitive.purple.100"
	ColorPrimitivePurple200    ColorToken = "primitive.purple.200"
	ColorPrimitivePurple300    ColorToken = "primitive.purple.300"
	ColorPrimitivePurple400    ColorToken = "primitive.purple.400"
	ColorPrimitivePurple500    ColorToken = "primitive.purple.500"
	ColorPrimitivePurple600    ColorToken = "primitive.purple.600"
	ColorPrimitivePurple700    ColorToken = "primitive.purple.700"
	ColorPrimitivePurple800    ColorToken = "primitive.purple.800"
	ColorPrimitivePurple900    ColorToken = "primitive.purple.900"
	ColorPrimitivePurple950    ColorToken = "primitive.purple.950"
	ColorPrimitiveFuchsia50    ColorToken = "primitive.fuchsia.50"
	ColorPrimitiveFuchsia100   ColorToken = "primitive.fuchsia.100"
	ColorPrimitiveFuchsia200   ColorToken = "primitive.fuchsia.200"
	ColorPrimitiveFuchsia300   ColorToken = "primitive.fuchsia.300"
	ColorPrimitiveFuchsia400   ColorToken = "primitive.fuchsia.400"
	ColorPrimitiveFuchsia500   ColorToken = "primitive.fuchsia.500"
	ColorPrimitiveFuchsia600   ColorToken = "primitive.fuchsia.600"
	ColorPrimitiveFuchsia700   ColorToken = "primitive.fuchsia.700"
	ColorPrimitiveFuchsia800   ColorToken = "primitive.fuchsia.800"
	ColorPrimitiveFuchsia900   ColorToken = "primitive.fuchsia.900"
	ColorPrimitiveFuchsia950   ColorToken = "primitive.fuchsia.950"
	ColorPrimitivePink50       ColorToken = "primitive.pink.50"
	ColorPrimitivePink100      ColorToken = "primitive.pink.100"
	ColorPrimitivePink200      ColorToken = "primitive.pink.200"
	ColorPrimitivePink300      ColorToken = "primitive.pink.300"
	ColorPrimitivePink400      ColorToken = "primitive.pink.400"
	ColorPrimitivePink500      ColorToken = "primitive.pink.500"
	ColorPrimitivePink600      ColorToken = "primitive.pink.600"
	ColorPrimitivePink700      ColorToken = "primitive.pink.700"
	ColorPrimitivePink800      ColorToken = "primitive.pink.800"
	ColorPrimitivePink900      ColorToken = "primitive.pink.900"
	ColorPrimitivePink950      ColorToken = "primitive.pink.950"
	ColorPrimitiveRose50       ColorToken = "primitive.rose.50"
	ColorPrimitiveRose100      ColorToken = "primitive.rose.100"
	ColorPrimitiveRose200      ColorToken = "primitive.rose.200"
	ColorPrimitiveRose300      ColorToken = "primitive.rose.300"
	ColorPrimitiveRose400      ColorToken = "primitive.rose.400"
	ColorPrimitiveRose500      ColorToken = "primitive.rose.500"
	ColorPrimitiveRose600      ColorToken = "primitive.rose.600"
	ColorPrimitiveRose700      ColorToken = "primitive.rose.700"
	ColorPrimitiveRose800      ColorToken = "primitive.rose.800"
	ColorPrimitiveRose900      ColorToken = "primitive.rose.900"
	ColorPrimitiveRose950      ColorToken = "primitive.rose.950"
	ColorPrimitiveSlate50      ColorToken = "primitive.slate.50"
	ColorPrimitiveSlate100     ColorToken = "primitive.slate.100"
	ColorPrimitiveSlate200     ColorToken = "primitive.slate.200"
	ColorPrimitiveSlate300     ColorToken = "primitive.slate.300"
	ColorPrimitiveSlate400     ColorToken = "primitive.slate.400"
	ColorPrimitiveSlate500     ColorToken = "primitive.slate.500"
	ColorPrimitiveSlate600     ColorToken = "primitive.slate.600"
	ColorPrimitiveSlate700     ColorToken = "primitive.slate.700"
	ColorPrimitiveSlate800     ColorToken = "primitive.slate.800"
	ColorPrimitiveSlate900     ColorToken = "primitive.slate.900"
	ColorPrimitiveSlate950     ColorToken = "primitive.slate.950"
	ColorPrimitiveGray50       ColorToken = "primitive.gray.50"
	ColorPrimitiveGray100      ColorToken = "primitive.gray.100"
	ColorPrimitiveGray200      ColorToken = "primitive.gray.200"
	ColorPrimitiveGray300      ColorToken = "primitive.gray.300"
	ColorPrimitiveGray400      ColorToken = "primitive.gray.400"
	ColorPrimitiveGray500      ColorToken = "primitive.gray.500"
	ColorPrimitiveGray600      ColorToken = "primitive.gray.600"
	ColorPrimitiveGray700      ColorToken = "primitive.gray.700"
	ColorPrimitiveGray800      ColorToken = "primitive.gray.800"
	ColorPrimitiveGray900      ColorToken = "primitive.gray.900"
	ColorPrimitiveGray950      ColorToken = "primitive.gray.950"
	ColorPrimitiveZinc50       ColorToken = "primitive.zinc.50"
	ColorPrimitiveZinc100      ColorToken = "primitive.zinc.100"
	ColorPrimitiveZinc200      ColorToken = "primitive.zinc.200"
	ColorPrimitiveZinc300      ColorToken = "primitive.zinc.300"
	ColorPrimitiveZinc400      ColorToken = "primitive.zinc.400"
	ColorPrimitiveZinc500      ColorToken = "primitive.zinc.500"
	ColorPrimitiveZinc600      ColorToken = "primitive.zinc.600"
	ColorPrimitiveZinc700      ColorToken = "primitive.zinc.700"
	ColorPrimitiveZinc800      ColorToken = "primitive.zinc.800"
	ColorPrimitiveZinc900      ColorToken = "primitive.zinc.900"
	ColorPrimitiveZinc950      ColorToken = "primitive.zinc.950"
	ColorPrimitiveNeutral50    ColorToken = "primitive.neutral.50"
	ColorPrimitiveNeutral100   ColorToken = "primitive.neutral.100"
	ColorPrimitiveNeutral200   ColorToken = "primitive.neutral.200"
	ColorPrimitiveNeutral300   ColorToken = "primitive.neutral.300"
	ColorPrimitiveNeutral400   ColorToken = "primitive.neutral.400"
	ColorPrimitiveNeutral500   ColorToken = "primitive.neutral.500"
	ColorPrimitiveNeutral600   ColorToken = "primitive.neutral.600"
	ColorPrimitiveNeutral700   ColorToken = "primitive.neutral.700"
	ColorPrimitiveNeutral800   ColorToken = "primitive.neutral.800"
	ColorPrimitiveNeutral900   ColorToken = "primitive.neutral.900"
	ColorPrimitiveNeutral950   ColorToken = "primitive.neutral.950"
	ColorPrimitiveStone50      ColorToken = "primitive.stone.50"
	ColorPrimitiveStone100     ColorToken = "primitive.stone.100"
	ColorPrimitiveStone200     ColorToken = "primitive.stone.200"
	ColorPrimitiveStone300     ColorToken = "primitive.stone.300"
	ColorPrimitiveStone400     ColorToken = "primitive.stone.400"
	ColorPrimitiveStone500     ColorToken = "primitive.stone.500"
	ColorPrimitiveStone600     ColorToken = "primitive.stone.600"
	ColorPrimitiveStone700     ColorToken = "primitive.stone.700"
	ColorPrimitiveStone800     ColorToken = "primitive.stone.800"
	ColorPrimitiveStone900     ColorToken = "primitive.stone.900"
	ColorPrimitiveStone950     ColorToken = "primitive.stone.950"
	ColorPrimitiveTaupe50      ColorToken = "primitive.taupe.50"
	ColorPrimitiveTaupe100     ColorToken = "primitive.taupe.100"
	ColorPrimitiveTaupe200     ColorToken = "primitive.taupe.200"
	ColorPrimitiveTaupe300     ColorToken = "primitive.taupe.300"
	ColorPrimitiveTaupe400     ColorToken = "primitive.taupe.400"
	ColorPrimitiveTaupe500     ColorToken = "primitive.taupe.500"
	ColorPrimitiveTaupe600     ColorToken = "primitive.taupe.600"
	ColorPrimitiveTaupe700     ColorToken = "primitive.taupe.700"
	ColorPrimitiveTaupe800     ColorToken = "primitive.taupe.800"
	ColorPrimitiveTaupe900     ColorToken = "primitive.taupe.900"
	ColorPrimitiveTaupe950     ColorToken = "primitive.taupe.950"
	ColorPrimitiveMauve50      ColorToken = "primitive.mauve.50"
	ColorPrimitiveMauve100     ColorToken = "primitive.mauve.100"
	ColorPrimitiveMauve200     ColorToken = "primitive.mauve.200"
	ColorPrimitiveMauve300     ColorToken = "primitive.mauve.300"
	ColorPrimitiveMauve400     ColorToken = "primitive.mauve.400"
	ColorPrimitiveMauve500     ColorToken = "primitive.mauve.500"
	ColorPrimitiveMauve600     ColorToken = "primitive.mauve.600"
	ColorPrimitiveMauve700     ColorToken = "primitive.mauve.700"
	ColorPrimitiveMauve800     ColorToken = "primitive.mauve.800"
	ColorPrimitiveMauve900     ColorToken = "primitive.mauve.900"
	ColorPrimitiveMauve950     ColorToken = "primitive.mauve.950"
	ColorPrimitiveMist50       ColorToken = "primitive.mist.50"
	ColorPrimitiveMist100      ColorToken = "primitive.mist.100"
	ColorPrimitiveMist200      ColorToken = "primitive.mist.200"
	ColorPrimitiveMist300      ColorToken = "primitive.mist.300"
	ColorPrimitiveMist400      ColorToken = "primitive.mist.400"
	ColorPrimitiveMist500      ColorToken = "primitive.mist.500"
	ColorPrimitiveMist600      ColorToken = "primitive.mist.600"
	ColorPrimitiveMist700      ColorToken = "primitive.mist.700"
	ColorPrimitiveMist800      ColorToken = "primitive.mist.800"
	ColorPrimitiveMist900      ColorToken = "primitive.mist.900"
	ColorPrimitiveMist950      ColorToken = "primitive.mist.950"
	ColorPrimitiveOlive50      ColorToken = "primitive.olive.50"
	ColorPrimitiveOlive100     ColorToken = "primitive.olive.100"
	ColorPrimitiveOlive200     ColorToken = "primitive.olive.200"
	ColorPrimitiveOlive300     ColorToken = "primitive.olive.300"
	ColorPrimitiveOlive400     ColorToken = "primitive.olive.400"
	ColorPrimitiveOlive500     ColorToken = "primitive.olive.500"
	ColorPrimitiveOlive600     ColorToken = "primitive.olive.600"
	ColorPrimitiveOlive700     ColorToken = "primitive.olive.700"
	ColorPrimitiveOlive800     ColorToken = "primitive.olive.800"
	ColorPrimitiveOlive900     ColorToken = "primitive.olive.900"
	ColorPrimitiveOlive950     ColorToken = "primitive.olive.950"
)

type ColorValue

type ColorValue struct {
	// contains filtered or unexported fields
}

ColorValue is either a literal color or a theme token.

func ColorRGBA

func ColorRGBA(r, g, b, a uint8) ColorValue

ColorRGBA creates an explicitly set literal paint color from RGBA channels, including transparent zero. Use RGBA for raw RGBAColor data instead.

func LiteralColor

func LiteralColor(value RGBAColor) ColorValue

LiteralColor wraps existing raw RGBA data as a literal paint color. Use ColorRGBA when supplying channels directly.

func TokenColor

func TokenColor(token ColorToken) ColorValue

TokenColor creates a token-backed paint color.

type ComponentTheme

type ComponentTheme struct {
	Base   StylePatch
	States StateStyles
}

ComponentTheme supplies semantic-token-backed defaults for one component.

type ComponentToken

type ComponentToken string

ComponentToken names a component-level theme entry.

type CornerValues

type CornerValues struct{ TopLeft, TopRight, BottomRight, BottomLeft MetricValue }

CornerValues contains radii in top-left, top-right, bottom-right, bottom-left order. Its zero-value fields are unset.

func Corners

func Corners(topLeft, topRight, bottomRight, bottomLeft float32) CornerValues

Corners creates explicit logical-unit radii in top-left, top-right, bottom-right, bottom-left order.

func Round

func Round(value float32) CornerValues

Round applies one literal logical-unit radius to every corner. The returned metrics are explicitly set, including when value is zero.

func UniformCorners

func UniformCorners(value MetricValue) CornerValues

UniformCorners applies one radius to every corner.

type Direction

type Direction uint8

Direction selects Box's main axis. Vertical is the zero value.

const (
	// Vertical lays out Box children from top to bottom and is the zero value.
	Vertical Direction = iota
	// Horizontal lays out Box children from left to right.
	Horizontal
)

type EdgeValues

type EdgeValues struct{ Top, Right, Bottom, Left MetricValue }

EdgeValues contains metrics in top, right, bottom, left order. Its zero-value fields are unset.

func Edges

func Edges(top, right, bottom, left float32) EdgeValues

Edges creates explicit logical-unit edges in top, right, bottom, left order.

func Margin

func Margin(value float32) EdgeValues

Margin applies one literal logical-unit metric to every edge, like Padding. The returned metrics are explicitly set, including when value is zero.

func MarginXY

func MarginXY(horizontal, vertical float32) EdgeValues

MarginXY applies literal logical-unit metrics to the horizontal and vertical edges, like PaddingXY. The returned metrics are explicitly set, including zero values.

func Padding

func Padding(value float32) EdgeValues

Padding applies one literal logical-unit metric to every edge. The returned metrics are explicitly set, including when value is zero.

func PaddingXY

func PaddingXY(horizontal, vertical float32) EdgeValues

PaddingXY applies literal logical-unit metrics to the horizontal and vertical edges. The returned metrics are explicitly set, including zero values.

func UniformEdges

func UniformEdges(value MetricValue) EdgeValues

UniformEdges applies one metric to every edge.

type Font

type Font struct {
	Family    FontFamily
	Weight    FontWeight
	Slant     FontSlant
	FaceIndex int
	// contains filtered or unexported fields
}

Font registers one TTF/OTF/TTC face. A FontBytes value owns its copied bytes for as long as that value or an App configured with it remains reachable. FontFile handles and all parsed faces live only from App.Run text startup until renderer teardown completes. The file is not copied into the Go heap. FaceIndex selects a collection face and is zero for ordinary fonts.

func FontBytes

func FontBytes(family FontFamily, data []byte) Font

FontBytes creates an application-owned font from a defensive copy of data.

func FontFile

func FontFile(family FontFamily, path string) Font

FontFile creates a font loaded from the exact path during App.Run startup. dxui does not search or copy the file into an application package.

func SystemFont

func SystemFont(family FontFamily) Font

SystemFont requests one of the documented generic system families. The resolver tests a fixed path list for the current OS and returns a startup error when none exists; it never depends on fontconfig or fuzzy name search.

type FontFamily

type FontFamily string

FontFamily is an application-visible family name used for deterministic ordered fallback. It is not an operating-system font handle.

const (
	// FontFamilyDefault is dxui's embedded, BSD-licensed Go Regular font. It
	// covers the MVP Latin samples but not CJK.
	FontFamilyDefault FontFamily = internaltext.BuiltinFamily
	// FontFamilySystemSans resolves one fixed candidate list per operating
	// system; it is never searched by fuzzy display name.
	FontFamilySystemSans FontFamily = "system-ui"
	// FontFamilySystemMono is the deterministic system monospace family.
	FontFamilySystemMono FontFamily = "system-monospace"
	// FontFamilySystemCJK is the deterministic system CJK fallback family.
	FontFamilySystemCJK FontFamily = "system-cjk"
)

type FontSlant

type FontSlant uint8

FontSlant selects a registered normal or italic face.

const (
	SlantNormal FontSlant = iota
	SlantItalic
)

type FontWeight

type FontWeight uint16

FontWeight selects the nearest registered face weight in a family.

const (
	WeightRegular FontWeight = 400
	WeightMedium  FontWeight = 500
	WeightBold    FontWeight = 700
)

type IconData

type IconData = icondata.Data

IconData is immutable dxui path data in ViewBox coordinates.

type IconProps

type IconProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior
	Data    IconData
	Size    float32
	Color   ColorValue
	// StrokeWidth uses icon view-box units and defaults to 2. Values must be
	// finite and non-negative; zero means the default rather than no stroke.
	StrokeWidth IconStrokeWidth
}

IconProps configures a vector icon. Size is measured in logical units; zero uses the current component theme default.

type IconStrokeWidth

type IconStrokeWidth float32

IconStrokeWidth is a stroke width in icon view-box units. Zero selects the Lucide default of 2. It affects immutable stroked resources and is ignored by legacy filled IconData.

type ImageFit

type ImageFit uint8

ImageFit selects the supported destination fitting policy.

const (
	ImageContain ImageFit = iota
	ImageCover
	ImageFill
	ImageNone
)

type ImageProps

type ImageProps struct {
	Key       string
	Style     Style
	Token     ComponentToken
	States    StateStyles
	Pointer   PointerBehavior
	Source    ImageSource
	Fit       ImageFit
	Alignment Point
	MaxPixels int64
	// OnLoad and OnError are optional notifications; nil does not stop decoding.
	OnLoad  func(Size)
	OnError func(error)
}

ImageProps configures a decoded raster image. Alignment components are in [0,1].

type ImageSource

type ImageSource struct {
	// contains filtered or unexported fields
}

ImageSource is an immutable, comparable handle to application image data.

func ImageBytes

func ImageBytes(data []byte) ImageSource

ImageBytes copies encoded PNG, JPEG, or GIF bytes immediately.

func ImageFile

func ImageFile(path string) ImageSource

ImageFile records a path that is read by the image engine on demand.

func ImageFromGo

func ImageFromGo(value image.Image) ImageSource

ImageFromGo records an immutable-by-contract Go image source.

type InputGroupContent

type InputGroupContent struct {
	Input  View
	Prefix Option[View]
	Suffix Option[View]
}

InputGroupContent identifies the required Input and optional adornments. Prefix and Suffix may contain passive views or Buttons; other focusable controls and nested text editors are rejected.

type InputGroupProps

type InputGroupProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior
}

InputGroupProps configures the non-focusable visual container around one Input and its optional leading and trailing content.

type InputProps

type InputProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior
	Value   string
	// OnChange proposes Value. Nil blocks editing and pre-edit, but preserves selection and copy.
	OnChange  func(string)
	Selection Option[TextRange]
	// OnSelectionChange reports rune selection. Nil retains internal selection; Selection, when set, wins on rebuild.
	OnSelectionChange func(TextRange)
	Placeholder       string
	Password          bool
	// ShowPasswordToggle adds an internal trailing visibility button only when
	// Password is also true. Visibility is temporary state owned by the Input.
	ShowPasswordToggle bool
	// Disabled removes focus, stops native text input, and cancels composition, drag, and press.
	Disabled bool
	// ReadOnly blocks edits and pre-edit while allowing focus, navigation, selection, and non-password copy.
	ReadOnly bool
	// OnSubmit handles Enter independently of OnChange and ReadOnly. Nil emits no submit; Disabled blocks it.
	OnSubmit func()
}

InputProps configures a controlled single-line input. OnChange receives the complete proposed value after committed text, paste, cut, deletion, undo, or redo. The application accepts the edit by returning that value from the next build; leaving Value unchanged rejects it. IME composition does not call OnChange. Selection and TextRange use rune indices. A nil OnChange makes the input read-only by behavior, without Disabled styling. ReadOnly also blocks pre-edit; focus, selection, non-password copy, and OnSubmit remain available.

type Insets

type Insets struct{ Top, Right, Bottom, Left Length }

Insets contains absolute-position insets.

type Justify

type Justify uint8

Justify controls main-axis alignment.

const (
	JustifyStart Justify = iota
	JustifyCenter
	JustifyEnd
	JustifySpaceBetween
)

type LayoutContext

type LayoutContext struct{ Width, Height float32 }

LayoutContext is the logical space available to the root builder. It contains no backend values. A constraint-aware build runs once initially and once for the final resize/scale event in each drained event batch.

type Length

type Length struct {
	// contains filtered or unexported fields
}

Length is an opaque automatic, logical-pixel, or percentage length. Its zero value means automatic sizing; use Px or Percent for an explicit value.

func Fill

func Fill() Length

Fill is the common full-available-axis length. It is equivalent to Percent(100) and remains subject to the parent's definite-size rules.

func Percent

func Percent(value float32) Length

Percent creates a percentage length in the range 0..100.

func Px

func Px(value float32) Length

Px creates a logical-pixel length.

type MenuItem struct {
	Value    string
	Label    string
	Disabled bool
}

MenuItem is one immutable action in a Menu. Value must be non-empty and unique within the component.

type MenuOrientation uint8

MenuOrientation selects the axis used to arrange Menu items.

const (
	MenuVertical MenuOrientation = iota
	MenuHorizontal
)
type MenuProps struct {
	Key         string
	Style       Style
	Token       ComponentToken
	States      StateStyles
	Pointer     PointerBehavior
	Orientation MenuOrientation
	Value       string
	Items       []MenuItem
	// Disabled cancels interaction and removes the focus stop.
	Disabled bool
	// OnAction invokes an enabled item, including the selected one. Nil retains navigation and visuals.
	OnAction func(string)
}

MenuProps configures an inline action list. Value optionally identifies the application-controlled selected item. Activating an enabled item calls OnAction with that item's Value, including when it is already selected.

type MetricToken

type MetricToken string

MetricToken names a theme metric.

type MetricValue

type MetricValue struct {
	// contains filtered or unexported fields
}

MetricValue is either a literal logical-unit metric or a theme token.

func Metric

func Metric(value float32) MetricValue

Metric creates a literal metric.

func TokenMetric

func TokenMetric(token MetricToken) MetricValue

TokenMetric creates a token-backed metric.

type Option

type Option[T any] struct {
	// contains filtered or unexported fields
}

Option distinguishes an explicitly supplied zero value from an unset value.

func NoShrink

func NoShrink() Option[float32]

NoShrink explicitly disables flex shrinking. It is equivalent to Some(0) and is distinct from an unset Shrink, whose default is one.

func Some

func Some[T any](value T) Option[T]

Some creates a set option.

type Overflow

type Overflow uint8

Overflow controls container clipping.

const (
	OverflowVisible Overflow = iota
	OverflowClip
)

type OverlayPlacement

type OverlayPlacement uint8

OverlayPlacement selects the preferred side and alignment of a window-level overlay. Placement automatically flips to the opposite side when it has more usable room and the preferred side cannot fit the content.

const (
	OverlayBottomStart OverlayPlacement = iota
	OverlayBottom
	OverlayBottomEnd
	OverlayTopStart
	OverlayTop
	OverlayTopEnd
	OverlayLeft
	OverlayRight
)

type PathCommand

type PathCommand = icondata.PathCommand

PathCommand stores up to three points. Move/Line use Points[0], Quad uses Points[0:2], and Cubic uses all three points.

type PathVerb

type PathVerb = icondata.PathVerb

PathVerb identifies one command in dxui's deliberately small vector icon format. It is not an SVG parser or a general scene graph.

type Point

type Point = icondata.Point

Point is a position or offset in logical units.

type PointerBehavior

type PointerBehavior uint8

PointerBehavior controls pointer participation for a view subtree.

const (
	PointerAuto PointerBehavior = iota
	// PointerNone excludes the view and all descendants. It is intended for
	// decorative overlays that must not intercept content below them.
	PointerNone
)

type PopoverProps

type PopoverProps struct {
	Key       string
	Style     Style
	Token     ComponentToken
	States    StateStyles
	Pointer   PointerBehavior
	Open      bool
	Placement OverlayPlacement
	Offset    MetricValue
	// OnOpenChange proposes Open. Nil leaves Open unchanged; open content remains interactive.
	OnOpenChange func(bool)
}

PopoverProps configures a controlled, interactive window-level overlay. Open is authoritative. Anchor activation, Escape, and an outside primary click submit the proposed state through OnOpenChange. Nil leaves Open unchanged and preserves open-content interaction. There is no Disabled or ReadOnly property; an anchor child does not disable the Popover host.

type Position

type Position uint8

Position controls normal-flow versus absolute layout.

const (
	PositionFlow Position = iota
	PositionAbsolute
)

type PrimitiveTokens

type PrimitiveTokens struct {
	Colors  map[ColorToken]RGBAColor
	Metrics map[MetricToken]float32
}

PrimitiveTokens are the literal foundation of a theme.

type ProgressBarProps

type ProgressBarProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior
	Value   float32
}

ProgressBarProps configures a deterministic, non-interactive progress indicator. Value is clamped to [0,1] for painting. NaN and negative infinity paint empty; positive infinity paints complete.

type RGBAColor

type RGBAColor struct{ R, G, B, A uint8 }

RGBAColor is an 8-bit non-premultiplied RGBA color.

The former Color type name is now the discoverable color-token namespace.

func RGBA

func RGBA(r, g, b, a uint8) RGBAColor

RGBA creates an 8-bit non-premultiplied color.

type RadioProps

type RadioProps struct {
	Key      string
	Style    Style
	Token    ComponentToken
	States   StateStyles
	Pointer  PointerBehavior
	Selected bool
	// Disabled cancels interaction and removes the focus stop.
	Disabled bool
	// OnSelect proposes selection of an unselected Radio. Nil preserves focus and press visuals.
	OnSelect func()
}

RadioProps configures a controlled radio button. Selected is authoritative; OnSelect is called only when an enabled, unselected Radio is activated.

type Rect

type Rect = icondata.Rect

Rect is a rectangle in logical units.

type RendererPreference

type RendererPreference uint8

RendererPreference selects the preferred renderer creation policy.

const (
	RendererAuto RendererPreference = iota
	RendererSoftware
)

type RuntimeDiagnostics

type RuntimeDiagnostics struct {
	SDLVersion             string
	RendererName           string
	LogicalSize            Size
	PixelSize              Size
	PixelDensity           float32
	DisplayScale           float32
	FrameCount             uint64
	WindowCreates          uint64
	RendererCreateAttempts uint64
	RendererCreates        uint64
	ExposeEvents           uint64
	ResizeEvents           uint64
	ScaleEvents            uint64
	NoopViewportEvents     uint64
	RendererResetEvents    uint64
	BuildCount             uint64
	LayoutCount            uint64
	PaintCount             uint64
	SoftwareFallback       bool
	CountersEnabled        bool
	EventCount             uint64
	ReconcileCount         uint64
	PaintNodeCount         uint64
	TextureCreates         uint64
	TextureDestroys        uint64
	CacheBytes             uint64
	CacheBudgetBytes       uint64
	CacheEntries           uint64
	FontResources          uint64
	ImageResources         uint64
	RendererResources      uint64
	Goroutines             int
	GoHeapBytes            uint64
	GoHeapObjects          uint64
	GoTotalAllocBytes      uint64
	GoMallocs              uint64
	EventToPresent         TimingSummary
	FrameTime              TimingSummary
}

RuntimeDiagnostics is a backend-neutral snapshot of the running or most recently stopped native runtime.

type ScrollAxis

type ScrollAxis uint8

ScrollAxis selects the axes whose content is measured without a maximum and whose retained offset may change.

const (
	ScrollVertical ScrollAxis = iota
	ScrollHorizontal
	ScrollBoth
)

type ScrollProps

type ScrollProps struct {
	Key           string
	Style         Style
	Token         ComponentToken
	States        StateStyles
	Pointer       PointerBehavior
	Axis          ScrollAxis
	InitialOffset Option[Point]
	Offset        Option[Point]
	Scrollbar     ScrollbarPolicy
	// OnScroll reports movement. Nil still scrolls internally when Offset is unset; a set Offset stays authoritative.
	OnScroll func(Point)
}

ScrollProps configures a one-child clipped viewport. Offset is authoritative when set. Otherwise InitialOffset is used only when the view is first mounted; later positions are preserved while the view keeps its identity. OnScroll reports the complete offset. Without Offset, movement updates retained state even with a nil callback; with Offset it only proposes a change. Scroll has no Disabled or ReadOnly property.

type ScrollbarPolicy

type ScrollbarPolicy uint8

ScrollbarPolicy controls the overlay scrollbar. Hidden suppresses scrollbar paint and pointer interaction without disabling wheel/trackpad scrolling.

const (
	ScrollbarAuto ScrollbarPolicy = iota
	ScrollbarAlways
	ScrollbarHidden
)

type SelectOption

type SelectOption struct {
	Value    string
	Label    string
	Disabled bool
}

SelectOption is one immutable entry in a Select. Value must be non-empty and unique within the Select; it is both the controlled application value and the stable identity used when options reorder.

type SelectProps

type SelectProps struct {
	Key         string
	Style       Style
	Token       ComponentToken
	States      StateStyles
	Pointer     PointerBehavior
	Value       string
	Options     []SelectOption
	Placeholder string
	// Disabled closes the popup, cancels interaction, and removes the focus stop.
	Disabled bool
	// OnChange proposes Value. Nil still allows popup browsing, navigation, and dismissal.
	OnChange func(string)
}

SelectProps configures a controlled custom popup Select. Value is authoritative; an empty or unmatched Value displays Placeholder.

type SemanticTokens

type SemanticTokens struct {
	Colors  map[ColorToken]ColorValue
	Metrics map[MetricToken]MetricValue
}

SemanticTokens map product meaning onto primitive or earlier semantic tokens. A literal ColorValue/MetricValue is also accepted.

type Shadow

type Shadow struct {
	OffsetX, OffsetY MetricValue
	Blur, Spread     MetricValue
	Color            ColorValue
}

Shadow is an outer paint-only shadow. MVP shadows support finite, non-negative blur/spread and are rendered by a bounded approximation.

type Shortcut

type Shortcut struct {
	Key       ShortcutKey
	Modifiers ShortcutModifiers
	Repeat    bool
	OnPress   func()
}

Shortcut binds one application-window key chord to a semantic action. Focused editors and built-in control keys have priority. Repeat enables repeated key-down activation; otherwise native repeat is consumed silently.

type ShortcutKey

type ShortcutKey uint8

ShortcutKey is a backend-neutral semantic key used by an App shortcut.

const (
	KeyEnter ShortcutKey = iota + 1
	KeyBackspace
	Key0
	Key1
	Key2
	Key3
	Key4
	Key5
	Key6
	Key7
	Key8
	Key9
	KeyPlus
	KeyMinus
	KeyMultiply
	KeyDivide
	KeyDecimal
	KeyEquals
)

type ShortcutModifiers

type ShortcutModifiers struct{ Shift, Control, Alt, Super, Primary bool }

ShortcutModifiers are matched exactly. Primary substitutes for Command on macOS and Control elsewhere; callers do not also set that physical field.

type Size

type Size struct{ Width, Height float32 }

Size is a width and height in logical units.

type SliderProps

type SliderProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior
	Value   float32
	Min     float32
	Max     float32
	Step    float32
	// Disabled cancels dragging and removes focus and pointer interaction.
	Disabled bool
	// OnChange proposes Value. Nil preserves focus and drag visuals without changing Value.
	OnChange func(float32)
}

SliderProps configures a controlled single-value horizontal slider. Value is authoritative; OnChange receives a clamped, step-aligned proposal. Zero Min and Max select the default 0..100 range. Step defaults to 1 when it is non-positive or non-finite. Other invalid ranges are inert.

type StateStyles

type StateStyles struct {
	Default  StylePatch
	Hover    StylePatch
	Focus    StylePatch
	Disabled StylePatch
	Pressed  StylePatch
	Checked  StylePatch
}

StateStyles contains the deterministic MVP visual-state cascade.

type Style

type Style struct {
	Width, Height       Length
	MinWidth, MinHeight Length
	MaxWidth, MaxHeight Length
	Margin, Padding     EdgeValues
	Position            Position
	Insets              Insets
	Grow                float32
	Shrink              Option[float32]
	Basis               Length
	AlignSelf           Option[Align]
	ZIndex              int
	Overflow            Overflow
	Background          ColorValue
	Border              Border
	Radius              CornerValues
	// Shadow is an explicitly requested list of outer shadows. A nil value
	// leaves a theme/state value unchanged; a non-nil empty slice removes it.
	Shadow     []Shadow
	Opacity    Option[float32]
	Visibility Visibility
	Text       TextStyle
	// Force is applied after component and interaction-state styles. It is for
	// deliberate paint overrides such as suppressing a focus ring; ordinary
	// base appearance belongs in the fields above so Hover/Pressed/Focus remain
	// visible. Force cannot affect layout.
	Force StylePatch
}

Style contains the supported layout, paint, and typography controls. Box is always single-line; there is intentionally no wrap or order property. The zero value is safe and selects intrinsic sizing and theme defaults.

type StylePatch

type StylePatch struct {
	Background Option[ColorValue]
	Border     Option[Border]
	Radius     Option[CornerValues]
	Shadow     Option[[]Shadow]
	Opacity    Option[float32]
	Visibility Option[Visibility]
	TextColor  Option[ColorValue]
}

StylePatch is an explicitly optional paint-only override. State styles are intentionally paint-only in MVP, so interaction never moves layout.

type TabItem

type TabItem struct {
	Value    string
	Label    string
	Disabled bool
}

TabItem is one immutable label in Tabs. Value must be non-empty and unique within the component.

type TabsProps

type TabsProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior
	Value   string
	Items   []TabItem
	// Disabled cancels interaction and removes the focus stop.
	Disabled bool
	// OnChange proposes a different Value. Nil retains active-item navigation and press visuals.
	OnChange func(string)
}

TabsProps configures a controlled horizontal tab selector. Value is authoritative; Tabs renders only the selector and applications render the corresponding content separately.

type TextAlign

type TextAlign uint8

TextAlign is horizontal alignment within a Text node's content box.

const (
	TextStart TextAlign = iota
	TextCenter
	TextEnd
)

type TextProps

type TextProps struct {
	Key      string
	Style    Style
	Token    ComponentToken
	States   StateStyles
	Pointer  PointerBehavior
	Value    string
	Wrap     TextWrap
	MaxLines int
}

TextProps configures simple left-to-right text. Invalid UTF-8 is normalized to U+FFFD when Text is constructed. TextWrapWords collapses whitespace and wraps only at word boundaries; it is not Unicode line-break conformance.

type TextRange

type TextRange struct{ Start, End int }

TextRange uses Unicode code-point (rune) offsets, never UTF-8 byte offsets.

type TextStyle

type TextStyle struct {
	Families   []FontFamily
	Size       float32
	LineHeight float32
	Weight     FontWeight
	Slant      FontSlant
	Color      ColorValue
	Align      TextAlign
}

TextStyle contains the simple-LTR/CJK MVP text inputs. Families are tried in order before the App default and built-in Latin fallback. Size is a font size in logical units; zero uses the current theme's default. LineHeight is a logical-unit line height; zero uses the current theme's default. Arabic/Indic shaping, bidi/RTL, color emoji, and vertical text are not supported by this API.

type TextWrap

type TextWrap uint8

TextWrap selects the MVP simple wrapping policy.

const (
	TextNoWrap TextWrap = iota
	TextWrapWords
)

type TextareaProps

type TextareaProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior
	Value   string
	// OnChange proposes Value. Nil blocks editing and pre-edit, but preserves selection and copy.
	OnChange  func(string)
	Selection Option[TextRange]
	// OnSelectionChange reports rune selection. Nil retains internal selection; Selection, when set, wins on rebuild.
	OnSelectionChange func(TextRange)
	Placeholder       string
	// Disabled removes focus, stops native text input, and cancels composition, drag, and press.
	Disabled bool
	// ReadOnly blocks edits and pre-edit while allowing focus, navigation, selection, and non-password copy.
	ReadOnly bool
	Wrap     TextWrap
}

TextareaProps configures a controlled multiline editor and follows the same controlled Value and rune-indexed selection contract as Input. TextWrapWords is a simple LTR/CJK word-wrap policy, not full Unicode line breaking. A nil OnChange preserves navigation, selection, copy, and scrolling without edits or pre-edit; it does not imply Disabled styling.

type Theme

type Theme struct {
	Primitive  PrimitiveTokens
	Semantic   SemanticTokens
	Components map[ComponentToken]ComponentTheme
}

Theme is the public, type-safe Primitive -> Semantic -> Component token structure. SetTheme validates and copies every map and slice atomically.

func DarkTheme

func DarkTheme() Theme

DarkTheme returns an independent, mutable-by-the-caller dark theme value.

func LightTheme

func LightTheme() Theme

LightTheme returns an independent, mutable-by-the-caller light theme value. App.SetTheme copies it before use.

type TimingSummary

type TimingSummary struct {
	Count, Samples      uint64
	P50NS, P95NS, P99NS int64
}

TimingSummary reports a bounded percentile distribution in nanoseconds.

type ToggleSwitchProps

type ToggleSwitchProps struct {
	Key     string
	Style   Style
	Token   ComponentToken
	States  StateStyles
	Pointer PointerBehavior
	// Checked is authoritative. Disabled cancels interaction and removes the focus stop.
	Checked, Disabled bool
	// OnChange proposes Checked. Nil preserves focus/press visuals without changing Checked.
	OnChange func(bool)
}

ToggleSwitchProps configures a controlled switch.

type TooltipProps

type TooltipProps struct {
	Key       string
	Style     Style
	Token     ComponentToken
	States    StateStyles
	Pointer   PointerBehavior
	Placement OverlayPlacement
	Offset    MetricValue
	Delay     time.Duration
	Disabled  bool
}

TooltipProps configures a non-interactive window-level hint. Hovering or keyboard-focusing the anchor starts Delay; leaving both closes it. A zero Delay selects the built-in 500 ms default.

type View

type View struct {
	// contains filtered or unexported fields
}

View is an immutable description. Its representation is deliberately private and never contains backend or SDL handles. The zero value is invalid as a root or child; a failed tree update leaves the last valid view visible.

func Avatar

func Avatar(props AvatarProps) View

Avatar creates a centered cover image with circular or square clipping.

Example
package main

import (
	"image"

	"github.com/dxui-org/dxui"
)

func main() {
	portrait := dxui.ImageFromGo(image.NewNRGBA(image.Rect(0, 0, 96, 64)))
	view := dxui.Avatar(dxui.AvatarProps{
		Source: portrait,
		Shape:  dxui.AvatarCircle,
		Size:   48,
	})
	_ = view
}

func Badge

func Badge(props BadgeProps, child View) View

Badge creates a compact, non-interactive one-child label.

Example
package main

import (
	"github.com/dxui-org/dxui"
)

func main() {
	view := dxui.Badge(
		dxui.BadgeProps{},
		dxui.Text(dxui.TextProps{Value: "New"}),
	)
	_ = view
}

func Box

func Box(props BoxProps, children ...View) View

Box creates a single-line flex description. Direction defaults to Vertical. Zero children are valid; a zero View among the supplied children is rejected transactionally.

func Button

func Button(props ButtonProps, child View) View

Button creates a semantic button description.

func ButtonGroup

func ButtonGroup(props ButtonGroupProps, buttons ...View) View

ButtonGroup creates a non-focusable horizontal or vertical group containing only Button views. Horizontal is the zero-value orientation.

func Checkbox

func Checkbox(props CheckboxProps, label View) View

Checkbox creates a controlled semantic checkbox with one label child.

func Icon

func Icon(props IconProps) View

Icon creates a lightweight vector icon description.

func Image

func Image(props ImageProps) View

Image creates a guarded raster image description.

func Input

func Input(props InputProps) View

Input creates a controlled, single-line input description.

func InputGroup

func InputGroup(props InputGroupProps, content InputGroupContent) View

InputGroup creates one horizontal visual control from a required Input and optional prefix/suffix views. The supplied Input keeps its own identity and editing state; the group suppresses only the Input's internal surface paint.

func Label

func Label(value string) View

Label creates text with the default text style.

func Menu(props MenuProps) View

Menu creates an inline vertical or horizontal action list with an optional controlled selected Value. Items are copied. Vertical is the zero value.

Example
package main

import (
	"github.com/dxui-org/dxui"
)

func main() {
	view := dxui.Menu(dxui.MenuProps{
		Value: "new",
		Items: []dxui.MenuItem{
			{Value: "new", Label: "New"},
			{Value: "archive", Label: "Archive", Disabled: true},
		},
		OnAction: func(value string) { _ = value },
	})
	_ = view
}

func Popover

func Popover(props PopoverProps, anchor, content View) View

Popover creates a controlled interactive overlay around one anchor and one content view. The content remains retained but is painted only in the window-level overlay layer while Open is true.

Example
package main

import (
	"github.com/dxui-org/dxui"
)

func main() {
	open := false
	view := dxui.Popover(dxui.PopoverProps{
		Open:         open,
		OnOpenChange: func(next bool) { open = next },
	}, dxui.Text(dxui.TextProps{Value: "Details"}),
		dxui.Button(dxui.ButtonProps{}, dxui.Text(dxui.TextProps{Value: "Action"})))
	_ = view
}

func ProgressBar

func ProgressBar(props ProgressBarProps) View

ProgressBar creates a deterministic, non-interactive progress indicator.

func Radio

func Radio(props RadioProps, label View) View

Radio creates a controlled semantic radio button with one label child.

func Scroll

func Scroll(props ScrollProps, child View) View

Scroll creates a clipped, one-child scrolling viewport.

func Select

func Select(props SelectProps) View

Select creates a controlled custom popup Select. Options are copied.

func Slider

func Slider(props SliderProps) View

Slider creates a controlled single-value horizontal slider description.

func Tabs

func Tabs(props TabsProps) View

Tabs creates a controlled horizontal tab selector. Items are copied.

Example
package main

import (
	"github.com/dxui-org/dxui"
)

func main() {
	section := "overview"
	view := dxui.Tabs(dxui.TabsProps{
		Value: section,
		Items: []dxui.TabItem{
			{Value: "overview", Label: "Overview"},
			{Value: "settings", Label: "Settings"},
		},
		OnChange: func(next string) { section = next },
	})
	_ = view // Render content separately according to section.
}

func Text

func Text(props TextProps) View

Text creates a text description.

func TextButton

func TextButton(props ButtonProps, label string) View

TextButton creates a Button whose text is centered in its content box. Use Button directly when the content is not a simple label.

func Textarea

func Textarea(props TextareaProps) View

Textarea creates a controlled multiline text editor description.

func ToggleSwitch

func ToggleSwitch(props ToggleSwitchProps) View

ToggleSwitch creates a controlled semantic switch description.

func Tooltip

func Tooltip(props TooltipProps, anchor, content View) View

Tooltip creates a delayed, non-interactive overlay around one anchor and one content view.

Example
package main

import (
	"time"

	"github.com/dxui-org/dxui"
)

func main() {
	view := dxui.Tooltip(dxui.TooltipProps{
		Placement: dxui.OverlayTop,
		Delay:     350 * time.Millisecond,
	}, dxui.Button(dxui.ButtonProps{}, dxui.Text(dxui.TextProps{Value: "Save"})),
		dxui.Text(dxui.TextProps{Value: "Save changes"}))
	_ = view
}

func VirtualList

func VirtualList(props VirtualListProps) View

VirtualList creates a vertical fixed-row virtualized viewport. The runtime builds only the visible rows plus the configured bounded overscan.

func (View) WithKey

func (view View) WithKey(key string) View

WithKey returns an independent description whose sibling-local key is key. The receiver and any descriptions that share its node are unchanged. This does not add a container or retained identity level.

func (View) WithStyle

func (view View) WithStyle(style Style) View

WithStyle returns an independent description whose complete local Style is style. Replacement is intentional: zero values, nil slices, and explicit empty slices keep their normal Style meanings. This does not add a container or retained identity level.

type VirtualListProps

type VirtualListProps struct {
	Key           string
	Style         Style
	Token         ComponentToken
	States        StateStyles
	Pointer       PointerBehavior
	Count         int
	Version       uint64
	RowHeight     float32
	Overscan      int
	InitialOffset Option[Point]
	Offset        Option[Point]
	Scrollbar     ScrollbarPolicy
	ItemKey       func(index int) string
	Build         func(index int) View
	OnScroll      func(Point)
}

VirtualListProps configures a vertical, fixed-row-height virtual list. Count and Version identify one immutable data snapshot; increment Version whenever row keys or content may have changed. ItemKey and Build run on the UI thread and must be deterministic and side-effect free for that snapshot.

type Visibility

type Visibility uint8

Visibility controls whether a node contributes display items.

const (
	Visible Visibility = iota
	Hidden
)

type Window

type Window struct {
	// contains filtered or unexported fields
}

Window is an opaque, concurrency-safe handle to a child native window. Component construction remains on the root dxui API; a Window only owns window-level lifecycle and scheduling operations.

func (*Window) Close

func (w *Window) Close()

Close closes this child window without affecting its owner or siblings. Repeated calls are no-ops.

func (*Window) Closed

func (w *Window) Closed() bool

Closed reports whether close has been requested or completed.

func (*Window) Diagnostics

func (w *Window) Diagnostics() RuntimeDiagnostics

Diagnostics returns this window's backend-neutral counters.

func (*Window) Invalidate

func (w *Window) Invalidate() error

Invalidate requests a rebuild of only this child window.

func (*Window) IsMaximized

func (w *Window) IsMaximized() bool

IsMaximized reports the latest state confirmed by native window events.

func (*Window) IsMinimized

func (w *Window) IsMinimized() bool

IsMinimized reports the latest state confirmed by native window events.

func (*Window) Maximize

func (w *Window) Maximize() error

Maximize requests the platform's maximized window state.

func (*Window) Minimize

func (w *Window) Minimize() error

Minimize requests the platform's minimized window state.

func (*Window) SetSize

func (w *Window) SetSize(width, height float32) error

SetSize requests a new positive logical client size. The resulting native viewport event drives layout; it is not presented speculatively.

func (*Window) SetTitle

func (w *Window) SetTitle(title string) error

SetTitle changes the native title on the UI thread. It may be called from a UI callback or App.Update closure and does not rebuild the root.

func (*Window) Size

func (w *Window) Size() Size

Size returns the latest known logical client size. Native resize events and successful SetSize calls update this snapshot.

func (*Window) Title

func (w *Window) Title() string

Title returns the last successfully configured title.

func (*Window) Unmaximize

func (w *Window) Unmaximize() error

Unmaximize restores a maximized window to its normal state.

func (*Window) Unminimize

func (w *Window) Unminimize() error

Unminimize restores a minimized window to its normal state.

func (*Window) Update

func (w *Window) Update(update func()) error

Update queues a child-window state mutation and rebuilds only that window.

type WindowOptions

type WindowOptions struct {
	Title               string
	Width, Height       float32
	MinWidth, MinHeight float32
	Background          RGBAColor
	Shortcuts           []Shortcut
	// OnCloseRequest may reject a native close request by returning without
	// calling Window.Close. A nil callback accepts the request.
	OnCloseRequest func(*Window)
	// OnShown runs once after the complete first frame is presented and the
	// hidden native window has been shown successfully.
	OnShown func(*Window)
}

WindowOptions configures an independent native child window. Theme, fonts, renderer preference, cache budgets and App shortcuts are inherited from the owning App. Callbacks execute on the App UI thread.

Directories

Path Synopsis
examples
calc command
Command calc is a four-function calculator styled after the supplied light/dark calculator reference.
Command calc is a four-function calculator styled after the supplied light/dark calculator reference.
components command
Command components runs the complete interactive dxui component showcase.
Command components runs the complete interactive dxui component showcase.
icon_gallery command
Command icon_gallery displays the complete generated Lucide catalog.
Command icon_gallery displays the complete generated Lucide catalog.
layout_gallery command
Command layout_gallery demonstrates the exact ADR-0005 layout subset using only the root dxui API.
Command layout_gallery demonstrates the exact ADR-0005 layout subset using only the root dxui API.
login command
Command login is the dxui MVP reference application.
Command login is the dxui MVP reference application.
minimal command
Command minimal opens one resizable dxui window and paints a solid background.
Command minimal opens one resizable dxui window and paints a solid background.
multi_window command
Command multi_window demonstrates one App event loop owning a main window and multiple independent native child windows.
Command multi_window demonstrates one App event loop owning a main window and multiple independent native child windows.
native_baseline command
Command native_baseline provides deterministic native measurement scenes.
Command native_baseline provides deterministic native measurement scenes.
scroll_gallery command
select_gallery command
style_gallery command
Command style_gallery demonstrates the M5 paint and theme slice using only the root dxui API.
Command style_gallery demonstrates the M5 paint and theme slice using only the root dxui API.
text_gallery command
Code generated from the OFL-licensed gallery font subset; DO NOT EDIT.
Code generated from the OFL-licensed gallery font subset; DO NOT EDIT.
virtual_list command
internal
backend
Package backend groups the ports required by the UI runtime.
Package backend groups the ports required by the UI runtime.
cmd/lucidegen command
Command lucidegen converts the pinned Lucide SVG release into immutable Go data.
Command lucidegen converts the pinned Lucide SVG release into immutable Go data.
icondata
Package icondata owns dxui's compact immutable vector-icon representation.
Package icondata owns dxui's compact immutable vector-icon representation.
image
Package image owns guarded pure-Go raster decoding and its byte-bounded CPU cache.
Package image owns guarded pure-Go raster decoding and its byte-bounded CPU cache.
input
Package input contains backend-independent controlled editing state.
Package input contains backend-independent controlled editing state.
layout
Package layout contains backend-independent logical-unit layout algorithms.
Package layout contains backend-independent logical-unit layout algorithms.
paint
Package paint owns backend-neutral display commands, replay state, stacking, hit testing, and dirty bounds.
Package paint owns backend-neutral display commands, replay state, stacking, hit testing, and dirty bounds.
platform
Package platform defines backend-neutral time and event ports.
Package platform defines backend-neutral time and event ports.
renderer
Package renderer defines backend-neutral paint execution ports.
Package renderer defines backend-neutral paint execution ports.
renderer/sdl3
Package sdl3 is the only production boundary allowed to import go-sdl3.
Package sdl3 is the only production boundary allowed to import go-sdl3.
runtime
Package runtime coordinates the event-driven UI-thread commit loop.
Package runtime coordinates the event-driven UI-thread commit loop.
text
Package text contains the pure-Go font registry, deterministic fallback, simple LTR/CJK layout, and grayscale glyph rasterization used by dxui.
Package text contains the pure-Go font registry, deterministic fallback, simple LTR/CJK layout, and grayscale glyph rasterization used by dxui.
theme
Package theme validates and resolves token layers without importing the public package.
Package theme validates and resolves token layers without importing the public package.
tree
Package tree owns retained identity, transactional reconciliation, dirty propagation, local state, and instance resource lifetimes.
Package tree owns retained identity, transactional reconciliation, dirty propagation, local state, and instance resource lifetimes.

Jump to

Keyboard shortcuts

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