Documentation
¶
Overview ¶
Package tone is the library's canonical color language: one Tone axis ("why is this thing colored"), one Hue axis ("which hue family"), and the two tables that map them to complete Tailwind class literals.
Before this package existed, the same semantic was modeled thirteen different ways (10 enums, 12 lookup maps, 3 palettes, ~10 fixed-color sites) — see docs/reviews/2026-10-15_color-domain-model.html. Phase 0 is ADDITIVE ONLY: existing enums gain adapters, existing lookup maps keep rendering, and equivalence tests prove the tables describe reality byte-for-byte. The maps collapse INTO these tables at v2 (ADR-0039/0044, TODO #431).
Scanner-safety contract ¶
Every class string in this package is a COMPLETE LITERAL, including the dark: prefixed half. Tailwind's scanner must see the whole token to emit CSS; variants are never concatenated at runtime (see AGENTS.md "Tailwind variant prefixes must be complete literals"). Pair exists to make the light/dark halves structural, not to build strings dynamically.
Warning dialect (resolved) ¶
The #428 decision (2026-10-30, owner default) landed ONE semantic warning hue: AMBER. The tone table, feedback (Alert/Toast), and Badge all render warning in amber; the former amber sites (StatusDot, ScrollbackLog, errorpage rejection, outline warning button, trend warn) already did. Categorical yellow survives on the Hue axis (Kanban lanes, StatCard series) — that is a pigment choice, not a semantic warning.
Index ¶
Constants ¶
const HueDefault = HueGray
HueDefault is the canonical default (Gray).
const ToneDefault = ToneNeutral
ToneDefault is the canonical default (Neutral).
Variables ¶
This section is empty.
Functions ¶
func ToneIsValid ¶
ToneIsValid reports whether t is a recognized Tone.
Types ¶
type ColorClass ¶
type ColorClass string
ColorClass is a complete, scanner-safe color utility string: the light class and its dark: half in ONE literal (e.g. "text-blue-600 dark:text-blue-400"). Chart series, spinners, and progress fills accept it so a typo cannot silently render nothing — pass a named constant (display.ChartColorBlue, …) or a complete literal of your own; a bare "text-blue-600" without the dark half compiles but trips the dark-mode guards.
The string kind keeps every existing untyped literal assigning (TODO #426 non-breaking); a typed value converts with string(c) where a raw string is needed.
type Hue ¶
type Hue string
Hue is the categorical hue family: which Tailwind color palette a class draws from, independent of meaning. Thirteen hues are in active use across the library's lookup tables (verified 2026-10-15); indigo is deliberately absent (nothing renders it).
Hue is for decisions that are genuinely categorical (chart series, kanban lanes, stat tiles): "the third series is violet" carries no semantics. When a color MEANS something, use Tone and let the tone table pick the hue.
const ( // Chart palette hues first, in canonical series order (line/pie/segment // charts cycle this order — chart_geometry.go, pie_chart.go). HueBlue Hue = "blue" HueEmerald Hue = "emerald" HueAmber Hue = "amber" HueRose Hue = "rose" HueViolet Hue = "violet" HueCyan Hue = "cyan" HueOrange Hue = "orange" HuePink Hue = "pink" // Semantic-dialect hues (the feedback/badge/kanban/stat families). HueGray Hue = "gray" HueGreen Hue = "green" HueYellow Hue = "yellow" HueRed Hue = "red" HuePurple Hue = "purple" )
type Pair ¶
type Pair struct {
// Light is the light-mode class literal, without any variant prefix
// (e.g. "text-green-600").
Light string
// Dark is the dark-mode class literal WITH its dark: prefix
// (e.g. "dark:text-green-400").
Dark string
}
Pair is one utility in light and dark form. Both halves are COMPLETE class literals — Dark carries its own dark: prefix — because Tailwind's scanner only emits CSS for tokens it can see in full (the package-level scanner-safety contract). Pair makes the halves structural so tests can prove every dark half exists.
func (Pair) Classes ¶
Classes returns the renderable class string: light and dark halves joined by a single space. Either half may be empty (single-mode utilities); the join never leaves leading/trailing whitespace.
type Surfaces ¶
type Surfaces struct {
// Dot is a solid indicator dot (status dots, kanban lane dots).
Dot Pair
// Text is body text on a tinted background (alert message text).
Text Pair
// TextSoft is de-emphasized text or an icon on a tinted background.
TextSoft Pair
// Border outlines a tinted container (alerts, tinted cards).
Border Pair
// BGTint is a soft tinted background (alert fills).
BGTint Pair
// BGSolid is a solid saturated fill (progress bars, pills).
BGSolid Pair
// Icon is an icon on a tinted background (alert icons).
Icon Pair
}
Surfaces is the per-tone rendering kit: which classes express a semantic tone on each surface kind. Values are anchored to the feedback dialect (Alert/Toast — the oldest and most-used semantic renderer), so For(ToneSuccess).Text is exactly the Text class feedbackStyleMap carries for success today.
type Tone ¶
type Tone string
Tone is the semantic reason something is colored: what the color MEANS, not which pigment it uses. Six values cover every color decision the library makes; hue-level (categorical) decisions use Hue instead.
const ( // ToneNeutral is the absence of semantic emphasis (gray). ToneNeutral Tone = "neutral" // ToneSuccess confirms a positive outcome (green). ToneSuccess Tone = "success" // ToneWarning signals caution short of failure (amber; see the // package doc's warning-dialect note and TODO #428). ToneWarning Tone = "warning" // ToneDanger signals failure or destruction (red). Canonical spelling // is "danger"; the FeedbackError value ("error") maps here via // FeedbackType.Tone() and collapses at v2. ToneDanger Tone = "danger" // ToneInfo is neutral-emphasis communication (blue). ToneInfo Tone = "info" // ToneAccent is the brand/primary slot (blue today; becomes the ADR-0044 // accent token family at v2). ToneAccent Tone = "accent" )
type Utilities ¶
type Utilities struct {
Text Pair
TextMuted Pair
TextStrong Pair
TextOnTint Pair
BGSolid Pair
BGSolidStrong Pair
BGTint Pair
Border Pair
}
Utilities is the per-hue class grammar: seven utility slots, each a complete light/dark Pair. The shade numbers are the library's uniform grammar, anchored to what the components actually render today:
Text 600 / dark:400 (chart series text, icons on tint) TextMuted 500 / dark:400 (muted neutral text — the gray-500 inverted convention) TextStrong 700 / dark:400 (trend arrows, log tags) TextOnTint 800 / dark:200 (body text on 50-tinted backgrounds) BGSolid 500 / dark:400 (status dots, kanban lane dots) BGSolidStrong 600 / dark:400 (segment bars, solid fills) BGTint 50 / dark:900/30 (stat tiles, icon chips) Border 200 / dark:800 (alert and card borders)
Gray carries two deliberate exceptions, kept to match shipped pixels: BGSolid is 400/dark:500 (the dot convention renders grays one step darker) and Border uses gray-700 in dark mode (the feedback neutral fallback). Cells no component uses yet are inert until adopted — the tables describe the grammar, the components choose the slots.
func UtilitiesFor ¶
UtilitiesFor returns the class grammar for h. Unknown hues fall back to Gray (the neutral default) — same contract as utils.Lookup.