kit

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package kit is Flatte's design-system components: pane headers, tabs, list rows, segmented choices, badges, sections, setting rows, empty states and popovers, built from layout nodes in the theme's roles (fills, text roles and colors) and token sizes (layout.RowSize, BarSize…). They hold no colors or lengths of their own, so a theme — its palette, density and roundness — restyles them all, in a window and in a terminal alike.

Each component is a plain struct; Layout builds its tree, as flatui widgets do. Components are stateless: selection, focus and values come from app state, and clicks arrive as MouseEvents targeting the IDs each one documents. Every slot that takes nodes (Actions, Trailing, Children) takes any layout.Node, so an app can put its own pieces where the recipe leaves room.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OptionID

func OptionID(id string, i int) string

OptionID is the node ID of a Segmented's option i.

Types

type Action

type Action struct {
	ID      string
	Icon    layout.IconName
	Glyph   string // the terminal spelling ("" : the icon's glyph)
	Tooltip string
}

Action is a small icon button inside a row, a tab or a pane header — a tab's close, a row's reveal: in a window a compact square with the hover wash under its icon, in a terminal its glyph. Its node ID is ID.

func (Action) Layout

func (a Action) Layout() layout.Node

type Badge

type Badge struct {
	Text string
	Tone Tone
}

Badge is a short status label on its tone's tint: a count, a state.

func (Badge) Layout

func (b Badge) Layout() layout.Node

type Disclosure

type Disclosure int

Disclosure is a tree row's expand state (ListRow.Disclosure).

const (
	// DisclosureNone is no chevron and no room for one (a flat list).
	DisclosureNone Disclosure = iota
	// DisclosureLeaf is the chevron's room, empty: a file among folders.
	DisclosureLeaf
	DisclosureClosed
	DisclosureOpen
)

type EmptyState

type EmptyState struct {
	ID      string
	Icon    layout.IconName
	Title   string
	Hint    string
	Actions []layout.Node
	// Inline sets it at the top left with the hint wrapping, for a narrow
	// sidebar, instead of centered in the pane.
	Inline bool
}

EmptyState fills a pane with nothing to show: an icon, a title, a hint and actions (buttons), centered.

func (EmptyState) Layout

func (e EmptyState) Layout() layout.Node

type ListRow

type ListRow struct {
	ID       string
	Icon     layout.IconName
	Title    string
	Meta     string
	Trailing []layout.Node
	Selected bool
	Active   bool
	Indent   int
	Disabled bool
	// Disclosure is a tree row's chevron, before the icon: DisclosureLeaf
	// keeps the chevron's room empty so leaves line up with folders.
	Disclosure Disclosure
	// TitleColor colors the title (and dims the icon with it) while the row
	// stays clickable: secondary files, disabled-grey ignored entries.
	TitleColor layout.TextColor
	// Italic sets the title in italics (a placeholder, a preview).
	Italic bool
}

ListRow is one row of a list or tree at the row height: an optional leading icon, a title, meta text after it, and trailing nodes (a badge, a count). Selected rows take the selection fill — the strong one when Active (the list has focus), the quiet one otherwise; rows show hover in a window. Indent shifts the content right by steps (tree depth).

func (ListRow) Layout

func (r ListRow) Layout() layout.Node

type PaneHeader

type PaneHeader struct {
	ID      string
	Title   string
	Meta    string
	Actions []layout.Node
	// Active brightens the caption while its pane has keyboard focus.
	Active bool
	// Body follows the title and takes the room before the actions: a
	// panel's tab strip (kit.Tabs), a filter field.
	Body layout.Node
}

PaneHeader is the bar on top of a pane or sidebar: a caption title, optional meta text beside it, and trailing actions (icon buttons, usually) at the right, on the chrome surface at the bar height.

func (PaneHeader) Layout

func (h PaneHeader) Layout() layout.Node

type Popover

type Popover struct {
	ID       string
	Anchor   string
	Width    layout.Size
	Children []layout.Node
}

Popover is a raised panel over the frame: a quick-open list, a menu of choices. Anchor places it under the node with that ID (empty: centered); Width is its width (zero: its content's).

func (Popover) Layout

func (p Popover) Layout() layout.Node

type Section

type Section struct {
	ID       string
	Title    string
	Children []layout.Node
}

Section is a group under a caption: settings, a sidebar's group.

func (Section) Layout

func (s Section) Layout() layout.Node

type Segmented

type Segmented struct {
	ID       string
	Options  []string
	Selected int
	Focused  bool
}

Segmented is a choice of a few options shown side by side, the chosen one filled. Option i's node ID is ID + ":" + its index (OptionID).

func (Segmented) Layout

func (s Segmented) Layout() layout.Node

type Setting

type Setting struct {
	ID          string
	Name        string
	Description string
	Control     layout.Node
}

Setting is a settings row: a name with an optional description under it, and the control (a toggle, a segmented choice, a field) at the right.

func (Setting) Layout

func (s Setting) Layout() layout.Node

type Tab

type Tab struct {
	ID       string
	Label    string
	Icon     layout.IconName
	Modified bool
	Italic   bool
	Close    string
}

Tab is one tab of a Tabs strip. Close is its close action's ID (empty: none); Modified shows a dot in the close action's place (an unsaved file), still clickable by the same ID. Italic marks a preview tab.

type Tabs

type Tabs struct {
	ID       string
	Tabs     []Tab
	Active   int
	Fill     bool
	Trailing []layout.Node
}

Tabs is a tab strip at the bar height on the chrome surface: the active tab sits on the content surface in strong text under an accent edge (Box.Edge, in a window), the others in secondary text. Each tab's node ID is Tab.ID; Trailing nodes (a new-tab button, a breadcrumb) follow the tabs directly. Fill shares the strip's width equally between the tabs (too many to fit at their names' width): long names end in "…".

func (Tabs) Layout

func (t Tabs) Layout() layout.Node

type Tone

type Tone int

Tone is a status color: badges and status text.

const (
	ToneNeutral Tone = iota
	ToneAccent
	ToneInfo
	ToneSuccess
	ToneWarning
	ToneDanger
)

Jump to

Keyboard shortcuts

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