Documentation
¶
Overview ¶
Package tw is a typed, allocation-efficient DSL for constructing Tailwind utility class strings from Go.
ClassList is an immutable builder. Every modifier returns a new value. Compile walks the internal segment list once and emits a deterministic space-separated string. The intended use is to build component base classes at package init time or inside pure view functions; runtime cost after the first Compile is negligible.
The package ships exhaustive typed enumerations for:
- layout (Display, Items, Justify, Position, FlexDir, ...)
- spacing and sizing (Spacing with S0..S64 + SPX, Width/Height/Min/Max variants, Gap...)
- semantic color roles (Surface*, Fg*, Border*, Ring* plus transparent/white/black)
- typography (FontSize, FontWeight, Tracking, Leading, FontFamily, TextAlign...)
- border, ring, shadow, radius, outline, opacity, cursor, ...
- motion (Transition, Duration, Easing, Translate...)
- state and responsive prefixes (State, Breakpoint) with func nesting
- z-index layers via ZLayer (arbitrary-value z-[N] emitted by .Class())
- plus many convenience methods (Truncate, SrOnly, LineClamp, Aspect*, GridCols, ...)
Prefixing via On(state, fn) and Breakpoint(bp, fn) supports arbitrary nesting and stacking. Merge and Raw provide composition and escape hatches.
A typed escape for non-Tailwind classes (your own CSS, design-system primitives, component data-handles, progress animations, etc.) is provided by the PlatformKitClass type and the PK method. Values are emitted verbatim.
Example ¶
import "github.com/septagon-oss/tw"
base := tw.New().
Display(tw.DisplayInlineFlex).
Items(tw.ItemsCenter).
Gap(tw.S2).
Rounded(tw.RadiusXL).
FontWeight(tw.FontSemibold).
Bg(tw.SurfaceBrand).
TextColor(tw.FgOnBrand).
On(tw.StateHover, func(c tw.ClassList) tw.ClassList {
return c.Bg(tw.SurfaceBrandHover)
}).
Compile()
All*() functions (AllColors, AllStates, AllRadii, AllZLayers, ...) are supplied for exhaustive tests and linter coverage of the compile tables.
See the godoc for the full method and constant list.
Index ¶
- type BorderStyle
- type BorderWidth
- type Breakpoint
- type ClassList
- func (cl ClassList) Accent(c Color) ClassList
- func (cl ClassList) AnimatePulse() ClassList
- func (cl ClassList) AnimateSpin() ClassList
- func (cl ClassList) AppearanceNone() ClassList
- func (cl ClassList) AspectRaw(raw string) ClassList
- func (cl ClassList) AspectSquare() ClassList
- func (cl ClassList) AspectVideo() ClassList
- func (cl ClassList) BackdropBlur(size string) ClassList
- func (cl ClassList) Bg(c Color) ClassList
- func (cl ClassList) BgOpacity(c Color, opacity string) ClassList
- func (cl ClassList) Border(b BorderWidth) ClassList
- func (cl ClassList) BorderBottom(b BorderWidth) ClassList
- func (cl ClassList) BorderBottomColor(c Color) ClassList
- func (cl ClassList) BorderColor(c Color) ClassList
- func (cl ClassList) BorderColorOpacity(c Color, opacity string) ClassList
- func (cl ClassList) BorderLeft(b BorderWidth) ClassList
- func (cl ClassList) BorderLeftColor(c Color) ClassList
- func (cl ClassList) BorderRight(b BorderWidth) ClassList
- func (cl ClassList) BorderRightColor(c Color) ClassList
- func (cl ClassList) BorderStyle(b BorderStyle) ClassList
- func (cl ClassList) BorderTop(b BorderWidth) ClassList
- func (cl ClassList) BorderTopColor(c Color) ClassList
- func (cl ClassList) Bottom(s Spacing) ClassList
- func (cl ClassList) BottomOffset(v PositionOffset) ClassList
- func (cl ClassList) BottomRaw(v string) ClassList
- func (cl ClassList) BreakAll() ClassList
- func (cl ClassList) BreakWords() ClassList
- func (cl ClassList) Breakpoint(bp Breakpoint, build func(ClassList) ClassList) ClassList
- func (cl ClassList) Capitalize() ClassList
- func (cl ClassList) ColSpan(n int) ClassList
- func (cl ClassList) ColSpanFull() ClassList
- func (cl ClassList) Compile() string
- func (cl ClassList) Container() ClassList
- func (cl ClassList) Cursor(c Cursor) ClassList
- func (cl ClassList) Display(d Display) ClassList
- func (cl ClassList) DivideX(s Spacing) ClassList
- func (cl ClassList) DivideY(s Spacing) ClassList
- func (cl ClassList) Duration(d Duration) ClassList
- func (cl ClassList) Easing(e Easing) ClassList
- func (cl ClassList) Flex1() ClassList
- func (cl ClassList) FlexDir(f FlexDir) ClassList
- func (cl ClassList) FlexGrow() ClassList
- func (cl ClassList) FlexGrow0() ClassList
- func (cl ClassList) FlexNoWrap() ClassList
- func (cl ClassList) FlexNone() ClassList
- func (cl ClassList) FlexShrink0() ClassList
- func (cl ClassList) FlexWrap() ClassList
- func (cl ClassList) FontFamily(f FontFamily) ClassList
- func (cl ClassList) FontSize(f FontSize) ClassList
- func (cl ClassList) FontWeight(f FontWeight) ClassList
- func (cl ClassList) Gap(s Spacing) ClassList
- func (cl ClassList) GapX(s Spacing) ClassList
- func (cl ClassList) GapY(s Spacing) ClassList
- func (cl ClassList) GridCols(n int) ClassList
- func (cl ClassList) GridColsRaw(raw string) ClassList
- func (cl ClassList) Group() ClassList
- func (cl ClassList) Height(s Spacing) ClassList
- func (cl ClassList) HeightRaw(v string) ClassList
- func (cl ClassList) HeightViewport(v ViewportHeight) ClassList
- func (cl ClassList) Inset(s Spacing) ClassList
- func (cl ClassList) InsetX(s Spacing) ClassList
- func (cl ClassList) InsetY(s Spacing) ClassList
- func (cl ClassList) IsEmpty() bool
- func (cl ClassList) Italic() ClassList
- func (cl ClassList) Items(i Items) ClassList
- func (cl ClassList) Justify(j Justify) ClassList
- func (cl ClassList) Leading(l Leading) ClassList
- func (cl ClassList) Left(s Spacing) ClassList
- func (cl ClassList) LeftOffset(v PositionOffset) ClassList
- func (cl ClassList) LeftRaw(v string) ClassList
- func (cl ClassList) Len() int
- func (cl ClassList) LineClamp(n int) ClassList
- func (cl ClassList) LineThrough() ClassList
- func (cl ClassList) ListStyle(style string) ClassList
- func (cl ClassList) Lowercase() ClassList
- func (cl ClassList) Margin(s Spacing) ClassList
- func (cl ClassList) MarginBottom(s Spacing) ClassList
- func (cl ClassList) MarginLeft(s Spacing) ClassList
- func (cl ClassList) MarginRight(s Spacing) ClassList
- func (cl ClassList) MarginTop(s Spacing) ClassList
- func (cl ClassList) MarginX(s Spacing) ClassList
- func (cl ClassList) MarginY(s Spacing) ClassList
- func (cl ClassList) MaxH(v string) ClassList
- func (cl ClassList) MaxHeight(s Spacing) ClassList
- func (cl ClassList) MaxHeightRaw(v string) ClassList
- func (cl ClassList) MaxHeightViewport(v ViewportHeight) ClassList
- func (cl ClassList) MaxW(name string) ClassList
- func (cl ClassList) MaxWScaled(name MaxWidth) ClassList
- func (cl ClassList) MaxWidthRaw(v string) ClassList
- func (cl ClassList) Merge(other ClassList) ClassList
- func (cl ClassList) MinH(v string) ClassList
- func (cl ClassList) MinHeight(s Spacing) ClassList
- func (cl ClassList) MinHeightRaw(v string) ClassList
- func (cl ClassList) MinWidth(s Spacing) ClassList
- func (cl ClassList) MinWidthRaw(v string) ClassList
- func (cl ClassList) NegBottom(s Spacing) ClassList
- func (cl ClassList) NegLeft(s Spacing) ClassList
- func (cl ClassList) NegMargin(side string, s Spacing) ClassList
- func (cl ClassList) NegRight(s Spacing) ClassList
- func (cl ClassList) NegTop(s Spacing) ClassList
- func (cl ClassList) NegTranslateX(raw string) ClassList
- func (cl ClassList) NegTranslateY(raw string) ClassList
- func (cl ClassList) NoLineThrough() ClassList
- func (cl ClassList) NoUnderline() ClassList
- func (cl ClassList) NormalCase() ClassList
- func (cl ClassList) NotItalic() ClassList
- func (cl ClassList) ObjectContain() ClassList
- func (cl ClassList) ObjectCover() ClassList
- func (cl ClassList) ObjectFit(fit string) ClassList
- func (cl ClassList) On(state State, build func(ClassList) ClassList) ClassList
- func (cl ClassList) Opacity(o Opacity) ClassList
- func (cl ClassList) Origin(side string) ClassList
- func (cl ClassList) Outline(o Outline) ClassList
- func (cl ClassList) Overflow(o Overflow) ClassList
- func (cl ClassList) OverflowX(o Overflow) ClassList
- func (cl ClassList) OverflowY(o Overflow) ClassList
- func (cl ClassList) OverscrollContain() ClassList
- func (cl ClassList) PK(c PlatformKitClass) ClassList
- func (cl ClassList) Padding(s Spacing) ClassList
- func (cl ClassList) PaddingBottom(s Spacing) ClassList
- func (cl ClassList) PaddingLeft(s Spacing) ClassList
- func (cl ClassList) PaddingRight(s Spacing) ClassList
- func (cl ClassList) PaddingTop(s Spacing) ClassList
- func (cl ClassList) PaddingTopRaw(v string) ClassList
- func (cl ClassList) PaddingX(s Spacing) ClassList
- func (cl ClassList) PaddingY(s Spacing) ClassList
- func (cl ClassList) Peer() ClassList
- func (cl ClassList) PointerEvents(p PointerEvents) ClassList
- func (cl ClassList) Position(p Position) ClassList
- func (cl ClassList) Raw(classes string) ClassList
- func (cl ClassList) Relative() ClassList
- func (cl ClassList) Resize(mode ResizeMode) ClassList
- func (cl ClassList) ResizeNone() ClassList
- func (cl ClassList) ResizeY() ClassList
- func (cl ClassList) Right(s Spacing) ClassList
- func (cl ClassList) RightOffset(v PositionOffset) ClassList
- func (cl ClassList) RightRaw(v string) ClassList
- func (cl ClassList) Ring(r RingWidth) ClassList
- func (cl ClassList) RingColor(c Color) ClassList
- func (cl ClassList) RingInset() ClassList
- func (cl ClassList) RingOffset(r RingOffset) ClassList
- func (cl ClassList) Rotate(deg string) ClassList
- func (cl ClassList) Rounded(r Radius) ClassList
- func (cl ClassList) RoundedBottom(r Radius) ClassList
- func (cl ClassList) RoundedLeft(r Radius) ClassList
- func (cl ClassList) RoundedRaw(v string) ClassList
- func (cl ClassList) RoundedRight(r Radius) ClassList
- func (cl ClassList) RoundedTop(r Radius) ClassList
- func (cl ClassList) Shadow(s Shadow) ClassList
- func (cl ClassList) SpaceX(s Spacing) ClassList
- func (cl ClassList) SpaceY(s Spacing) ClassList
- func (cl ClassList) SrOnly() ClassList
- func (cl ClassList) TabularNums() ClassList
- func (cl ClassList) TextAlign(t TextAlign) ClassList
- func (cl ClassList) TextColor(c Color) ClassList
- func (cl ClassList) TextColorOpacity(c Color, opacity string) ClassList
- func (cl ClassList) Top(s Spacing) ClassList
- func (cl ClassList) TopOffset(v PositionOffset) ClassList
- func (cl ClassList) TopRaw(v string) ClassList
- func (cl ClassList) Tracking(t Tracking) ClassList
- func (cl ClassList) Transform() ClassList
- func (cl ClassList) Transition(t Transition) ClassList
- func (cl ClassList) TranslateX(t Translate) ClassList
- func (cl ClassList) TranslateXRaw(raw string) ClassList
- func (cl ClassList) TranslateXStep(s Spacing) ClassList
- func (cl ClassList) TranslateY(t Translate) ClassList
- func (cl ClassList) TranslateYRaw(raw string) ClassList
- func (cl ClassList) TranslateYStep(s Spacing) ClassList
- func (cl ClassList) Truncate() ClassList
- func (cl ClassList) Underline() ClassList
- func (cl ClassList) UnderlineOffset(step Spacing) ClassList
- func (cl ClassList) Uppercase() ClassList
- func (cl ClassList) UserSelect(s Select) ClassList
- func (cl ClassList) WhitespaceNowrap() ClassList
- func (cl ClassList) WhitespacePreWrap() ClassList
- func (cl ClassList) Width(s Spacing) ClassList
- func (cl ClassList) WidthRaw(v string) ClassList
- func (cl ClassList) ZIndex(z ZLayer) ClassList
- func (cl ClassList) ZIndexRaw(raw string) ClassList
- func (cl ClassList) ZLayer(z ZLayer) ClassList
- type Color
- type Cursor
- type Display
- type Duration
- type Easing
- type FlexDir
- type FontFamily
- type FontSize
- type FontWeight
- type Items
- type Justify
- type Leading
- type MaxWidth
- type Opacity
- type Outline
- type Overflow
- type PlatformKitClass
- type PointerEvents
- type Position
- type PositionOffset
- type Radius
- type ResizeMode
- type RingOffset
- type RingWidth
- type Select
- type Shadow
- type Shape
- type Size
- type Spacing
- type State
- type TextAlign
- type Tracking
- type Transition
- type Translate
- type Variant
- type ViewportHeight
- type ZLayer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BorderStyle ¶
type BorderStyle string
BorderStyle is a typed border-style utility (dashed / solid / dotted). The Border() method sets width + base "border"; BorderStyle() layers the style on top.
const ( BorderSolid BorderStyle = "solid" BorderDashed BorderStyle = "dashed" BorderDotted BorderStyle = "dotted" BorderDouble BorderStyle = "double" BorderHidden BorderStyle = "hidden" BorderNone BorderStyle = "none" )
func AllBorderStyles ¶
func AllBorderStyles() []BorderStyle
AllBorderStyles returns every BorderStyle const in stable order.
type BorderWidth ¶
type BorderWidth string
BorderWidth is a typed border thickness step.
const ( Border0 BorderWidth = "0" Border1 BorderWidth = "" // base `border` class, no suffix Border2 BorderWidth = "2" // border-2 Border4 BorderWidth = "4" Border8 BorderWidth = "8" )
func AllBorderWidths ¶
func AllBorderWidths() []BorderWidth
AllBorderWidths returns every BorderWidth in stable order.
type Breakpoint ¶
type Breakpoint string
Breakpoint is a typed responsive breakpoint (Tailwind defaults).
const ( BreakpointSM Breakpoint = "sm" // >= 640px BreakpointMD Breakpoint = "md" // >= 768px BreakpointLG Breakpoint = "lg" // >= 1024px BreakpointXL Breakpoint = "xl" // >= 1280px Breakpoint2XL Breakpoint = "2xl" // >= 1536px )
func AllBreakpoints ¶
func AllBreakpoints() []Breakpoint
AllBreakpoints returns every Breakpoint const in stable order.
func (Breakpoint) IsZero ¶
func (b Breakpoint) IsZero() bool
func (Breakpoint) Prefix ¶
func (b Breakpoint) Prefix() string
Prefix returns the Tailwind breakpoint prefix including the trailing colon, e.g. "sm:". Zero value returns empty string (no prefix).
type ClassList ¶
type ClassList struct {
// contains filtered or unexported fields
}
ClassList is an immutable, composable typed builder for Tailwind class strings. Every method returns a new ClassList; the builder itself holds no resolved strings until Compile() is called.
The IR is a flat slice of segments. A segment is either:
- A utility class (resolved at append time, already a string)
- A prefix frame (opens a group like "hover:") and its end marker
This flat design lets Compile() walk the segments once, tracking the active prefix stack, and emit the final space-separated output in O(n).
Example (Basic) ¶
package main
import (
"fmt"
"github.com/septagon-oss/tw"
)
func main() {
cls := tw.New().
Display(tw.DisplayFlex).
Items(tw.ItemsCenter).
Gap(tw.S2).
PaddingX(tw.S4).
Rounded(tw.RadiusXL).
FontWeight(tw.FontSemibold).
Compile()
fmt.Println(cls)
}
Output: flex items-center gap-2 px-4 rounded-xl font-semibold
Example (BreakpointAndMerge) ¶
package main
import (
"fmt"
"github.com/septagon-oss/tw"
)
func main() {
base := tw.New().Padding(tw.S4).Rounded(tw.RadiusMD)
responsive := base.Merge(
tw.New().Breakpoint(tw.BreakpointMD, func(c tw.ClassList) tw.ClassList {
return c.Padding(tw.S6)
}),
)
fmt.Println(responsive.Compile())
}
Output: p-4 rounded-md md:p-6
Example (ColorsAndStates) ¶
package main
import (
"fmt"
"github.com/septagon-oss/tw"
)
func main() {
cls := tw.New().
Bg(tw.SurfacePrimary).
TextColor(tw.FgPrimary).
On(tw.StateHover, func(c tw.ClassList) tw.ClassList {
return c.Bg(tw.SurfaceHover).TextColor(tw.FgPrimary)
}).
Compile()
fmt.Println(cls)
}
Output: bg-surface-primary text-fg-primary hover:bg-surface-hover hover:text-fg-primary
Example (RawAndCompileEmpty) ¶
package main
import (
"fmt"
"github.com/septagon-oss/tw"
)
func main() {
// Raw is the escape hatch for runtime-computed or legacy values.
// Prefer the typed API for all static utilities.
hybrid := tw.New().Flex1().Raw("data-active").Compile()
fmt.Printf("%q\n", hybrid)
empty := tw.New().Compile()
fmt.Printf("empty=%q\n", empty)
}
Output: "flex-1 data-active" empty=""
Example (ZLayerAndCustom) ¶
package main
import (
"fmt"
"github.com/septagon-oss/tw"
)
func main() {
// ZLayer produces arbitrary-value z-* classes from typed numeric layers.
modal := tw.New().ZLayer(tw.ZModal).Compile()
fmt.Println(modal)
// PlatformKitClass (or your own typed alias) lets non-Tailwind classes
// flow through the same builder without triggering utility-only linters.
custom := tw.New().PK(tw.PlatformKitClass("my-custom-handle")).Compile()
fmt.Println(custom)
}
Output: z-[1400] my-custom-handle
func (ClassList) Accent ¶
Accent applies an accent color (Tailwind's "accent-*"). Used by form controls like range inputs and checkboxes to tint the native chrome with a design-system color.
func (ClassList) AnimatePulse ¶
AnimatePulse applies Tailwind's "animate-pulse" utility.
func (ClassList) AnimateSpin ¶
AnimateSpin applies Tailwind's "animate-spin" utility.
func (ClassList) AppearanceNone ¶
AppearanceNone removes native OS chrome from form controls.
func (ClassList) AspectRaw ¶
AspectRaw applies an arbitrary-value aspect ratio, e.g. "4/3" → "aspect-4/3". Prefer AspectVideo()/AspectSquare() when they match.
func (ClassList) AspectSquare ¶
AspectSquare / AspectVideo set aspect-ratio.
func (ClassList) AspectVideo ¶
func (ClassList) BackdropBlur ¶
BackdropBlur applies a backdrop-blur utility.
func (ClassList) BgOpacity ¶
BgOpacity sets a background color with an alpha modifier, e.g. Bg(SurfaceOverlay, "75") → "bg-surface-overlay/75".
func (ClassList) Border ¶
func (cl ClassList) Border(b BorderWidth) ClassList
Border applies a border width (use BorderColor for the color). The zero BorderWidth (Border1) emits the base "border" class.
func (ClassList) BorderBottom ¶
func (cl ClassList) BorderBottom(b BorderWidth) ClassList
func (ClassList) BorderBottomColor ¶
func (ClassList) BorderColor ¶
BorderColor applies a border color.
func (ClassList) BorderColorOpacity ¶
BorderColorOpacity sets a border color with an alpha modifier, e.g. BorderColorOpacity(ColorWhite, "30") → "border-white/30".
func (ClassList) BorderLeft ¶
func (cl ClassList) BorderLeft(b BorderWidth) ClassList
func (ClassList) BorderLeftColor ¶
func (ClassList) BorderRight ¶
func (cl ClassList) BorderRight(b BorderWidth) ClassList
func (ClassList) BorderRightColor ¶
func (ClassList) BorderStyle ¶
func (cl ClassList) BorderStyle(b BorderStyle) ClassList
BorderStyle applies a border-style utility (e.g., border-dashed). Use alongside Border() for width and BorderColor() for color.
func (ClassList) BorderTop ¶
func (cl ClassList) BorderTop(b BorderWidth) ClassList
BorderTop / BorderBottom / BorderLeft / BorderRight apply a one-side border width. Pass Border1 for the default thickness.
func (ClassList) BorderTopColor ¶
BorderTopColor / BorderBottomColor / BorderLeftColor / BorderRightColor apply a per-side border color, e.g. BorderTopColor(ColorWhite) → "border-t-white". Use alongside BorderTop etc. for the width.
func (ClassList) BottomOffset ¶ added in v0.2.3
func (cl ClassList) BottomOffset(v PositionOffset) ClassList
func (ClassList) BreakAll ¶
BreakAll lets a browser break a line at any character (Tailwind's "break-all"). Use for user-supplied long tokens like hashes / URLs.
func (ClassList) BreakWords ¶
BreakWords allows long words to break.
func (ClassList) Breakpoint ¶
func (cl ClassList) Breakpoint(bp Breakpoint, build func(ClassList) ClassList) ClassList
Breakpoint wraps the build function's output in a responsive prefix (e.g., "sm:"). Nested Breakpoint calls are supported.
func (ClassList) Capitalize ¶
func (ClassList) ColSpan ¶
ColSpan applies a CSS grid column span ("col-span-N"). N must be positive; 0 or negative → empty.
func (ClassList) ColSpanFull ¶
ColSpanFull emits Tailwind's "col-span-full" — span every column of the current grid regardless of column count. Distinct from ColSpan(N) which takes a numeric count.
func (ClassList) Compile ¶
Compile resolves the builder into a space-separated Tailwind class string. Output is deterministic and matches the append order. Prefix frames apply their prefix to each utility class between the open/close markers.
func (ClassList) Container ¶
Container applies Tailwind's responsive "container" utility — an element whose max-width steps through the configured breakpoints. Typically paired with MarginX(SAuto) for horizontal centering.
func (ClassList) DivideX ¶
DivideX / DivideY add borders between adjacent children. Pass empty Spacing for default; pass a Spacing const for a specific width.
func (ClassList) FlexNoWrap ¶
FlexNoWrap forces all flex children onto a single line — Tailwind's "flex-nowrap" utility. Use alongside Overflow to show a scroll when items exceed the container.
func (ClassList) FlexNone ¶
FlexGrow / FlexGrow0 toggle the flex-grow property. FlexNone prevents a flex child from growing or shrinking — Tailwind's "flex-none" utility.
func (ClassList) FlexShrink0 ¶
FlexShrink0 prevents a flex child from shrinking below its intrinsic size — Tailwind's "flex-shrink-0" utility.
func (ClassList) FlexWrap ¶
FlexWrap allows flex children to wrap to the next line — Tailwind's "flex-wrap" utility. Complements FlexDir for multi-line flex rows.
func (ClassList) FontFamily ¶
func (cl ClassList) FontFamily(f FontFamily) ClassList
FontFamily applies a font-family (Tailwind's font-sans/serif/mono).
func (ClassList) FontWeight ¶
func (cl ClassList) FontWeight(f FontWeight) ClassList
FontWeight applies a font-weight.
func (ClassList) GridCols ¶
GridCols applies a CSS grid template with N equally-sized columns ("grid-cols-N"). Use together with Display(DisplayGrid).
func (ClassList) GridColsRaw ¶
GridColsRaw applies an arbitrary-value grid template, e.g. "[auto_1fr]" → "grid-cols-[auto_1fr]". Reserved for non-integer column templates not expressible via GridCols.
func (ClassList) Group ¶
Group / Peer apply Tailwind's variant-enabler utilities. A parent with `group` exposes `group-hover:*` / `group-focus:*` to descendants; `peer` does the same for siblings via `peer-*`.
func (ClassList) HeightRaw ¶
HeightRaw applies a raw height value such as "[60vh]" — an arbitrary viewport/px/rem height outside the Spacing scale.
func (ClassList) HeightViewport ¶ added in v0.2.4
func (cl ClassList) HeightViewport(v ViewportHeight) ClassList
HeightViewport sets a height from the governed viewport-relative scale.
func (ClassList) LeftOffset ¶ added in v0.2.3
func (cl ClassList) LeftOffset(v PositionOffset) ClassList
LeftOffset / RightOffset / TopOffset / BottomOffset apply one governed fractional overlay position. Unlike the Raw forms, every accepted value is part of emission's closed utility universe.
func (ClassList) LeftRaw ¶
LeftRaw / TopRaw / BottomRaw / RightRaw apply fractional or arbitrary-value positional offsets that aren't on the Spacing scale, like "left-1/2" or "top-full". The only raw Tailwind literal lives in tw/compile.go — callers pass a typed RawOffset string.
func (ClassList) Len ¶
Len returns the number of segments currently in the builder. Exposed for tests — do not rely on it for runtime logic.
func (ClassList) LineClamp ¶
LineClamp truncates a paragraph after N lines (Tailwind's "line-clamp-N"). Use N >= 1; N == 0 emits "line-clamp-none".
func (ClassList) LineThrough ¶
LineThrough / NotLineThrough set the line-through text-decoration.
func (ClassList) MarginBottom ¶
func (ClassList) MarginLeft ¶
MarginLeft / MarginRight / MarginTop / MarginBottom — per-side margin.
func (ClassList) MarginRight ¶
func (ClassList) MaxHeight ¶ added in v0.2.4
MaxHeight sets max-height from the governed spacing scale.
func (ClassList) MaxHeightRaw ¶
MaxHeightRaw applies a raw max-height value such as "[72]" or "[6rem]" — for arbitrary pixel/rem heights outside the named MaxH scale.
func (ClassList) MaxHeightViewport ¶ added in v0.2.4
func (cl ClassList) MaxHeightViewport(v ViewportHeight) ClassList
MaxHeightViewport sets a max-height from the governed viewport-relative scale.
func (ClassList) MaxW ¶
MaxW sets max-width using Tailwind's named scale. Use MaxWScale for spacing-based max-widths (max-w-<step>).
func (ClassList) MaxWScaled ¶
MaxWScaled applies Tailwind's named max-width scale via a typed handle. Distinct from MaxW which takes an untyped string.
func (ClassList) MaxWidthRaw ¶
MaxWidthRaw applies a raw max-width value such as "[30rem]" or "[80px]" — for arbitrary pixel/rem widths outside the named MaxWidth scale.
func (ClassList) MinH ¶
MinH sets min-height. Accepts Spacing const names plus special values like "screen" / "full".
func (ClassList) MinHeightRaw ¶
MinHeightRaw applies a raw min-height value such as "[6rem]". Reserved for arbitrary-value utilities outside the Spacing scale.
func (ClassList) MinWidthRaw ¶
MinWidthRaw applies a raw min-width value such as "[3ch]" or "0". Reserved for arbitrary-value utilities outside the Spacing scale.
func (ClassList) NegMargin ¶
NegMargin sets a negative margin on the requested side. side is one of "" (all sides), "t", "b", "l", "r", "x", "y".
func (ClassList) NegTop ¶
NegTop / NegRight / NegBottom / NegLeft apply a negative positional offset on the Spacing scale (e.g., NegTop(tw.S1) emits "-top-1"). Used by badge and pill patterns that sit outside the parent's bounding box.
func (ClassList) NegTranslateX ¶
func (ClassList) NegTranslateY ¶
func (ClassList) NoLineThrough ¶
func (ClassList) NoUnderline ¶
NoUnderline removes underline text-decoration.
func (ClassList) NormalCase ¶
func (ClassList) ObjectContain ¶
ObjectContain applies Tailwind's "object-contain" utility — scales the content to fit without cropping.
func (ClassList) ObjectCover ¶
ObjectCover is a shorthand for ObjectFit("cover").
func (ClassList) On ¶
On wraps the build function's output in a state prefix (e.g., "hover:"). Nested On calls are supported and prefixes stack in order.
func (ClassList) OverscrollContain ¶
OverscrollContain sets overscroll-behavior to contain (Tailwind's "overscroll-contain"). Prevents scroll chaining out of a container.
func (ClassList) PK ¶
func (cl ClassList) PK(c PlatformKitClass) ClassList
PK appends a custom (non-Tailwind) class to the ClassList. The value is emitted verbatim. Use this for anything that should not be interpreted as a Tailwind utility (e.g. your "pk-*" animation classes, admin chrome handles, or arbitrary component markers).
func (ClassList) PaddingBottom ¶
func (ClassList) PaddingLeft ¶
PaddingLeft / PaddingRight / PaddingTop / PaddingBottom — per-side padding.
func (ClassList) PaddingRight ¶
func (ClassList) PaddingTop ¶
func (ClassList) PaddingTopRaw ¶
PaddingTopRaw applies a raw padding-top value such as "[20vh]" — an arbitrary-value padding outside the Spacing scale. Used for viewport- relative vertical padding (command palette top offset, hero layouts).
func (ClassList) PointerEvents ¶
func (cl ClassList) PointerEvents(p PointerEvents) ClassList
PointerEvents applies a pointer-events style.
func (ClassList) Raw ¶
Raw is the escape hatch. Pass pre-audited Tailwind classes straight through. Use only for runtime-computed values (e.g., HTMX attributes) or incremental migration; the typed tables and All* enumerators linter watches this.
func (ClassList) Resize ¶
func (cl ClassList) Resize(mode ResizeMode) ClassList
Resize applies a textarea-resize mode (`none` / `y` / `x` / `both`).
func (ClassList) ResizeNone ¶
ResizeNone is a shorthand for Resize(ResizeModeNone): disables the textarea resize handle entirely.
func (ClassList) ResizeY ¶
ResizeY is a shorthand for Resize(ResizeModeY): allows vertical resize only (the default for auto-grow textareas).
func (ClassList) RightOffset ¶ added in v0.2.3
func (cl ClassList) RightOffset(v PositionOffset) ClassList
func (ClassList) RingInset ¶
RingInset makes the focus ring draw on the inside edge of the element — Tailwind's "ring-inset" utility.
func (ClassList) RingOffset ¶
func (cl ClassList) RingOffset(r RingOffset) ClassList
RingOffset applies a ring offset width.
func (ClassList) Rotate ¶
Rotate sets a Tailwind rotate-* transform. deg is a numeric step like "45", "90", "180" matching the Tailwind rotate scale.
func (ClassList) RoundedBottom ¶
func (ClassList) RoundedLeft ¶
func (ClassList) RoundedRaw ¶
RoundedRaw applies a raw border-radius value such as "[20px]" — an arbitrary-value radius outside the Radius scale.
func (ClassList) RoundedRight ¶
func (ClassList) RoundedTop ¶
RoundedTop / RoundedBottom / RoundedLeft / RoundedRight apply a per-side border-radius step. Use Rounded(...) for all four corners.
func (ClassList) SpaceX ¶
SpaceX / SpaceY add horizontal / vertical spacing between adjacent sibling elements (Tailwind's "space-x-*" / "space-y-*").
func (ClassList) TabularNums ¶
TabularNums applies Tailwind's "tabular-nums" font-variant-numeric utility — forces fixed-width digits, used by counter displays.
func (ClassList) TextColor ¶
TextColor applies a foreground color. (Named TextColor rather than Text to avoid collision with FontSize.)
func (ClassList) TextColorOpacity ¶
TextColorOpacity sets a text color with an alpha modifier, e.g. TextColorOpacity(ColorWhite, "80") → "text-white/80".
func (ClassList) Top ¶
Positional offsets. Apply to an absolutely/fixed positioned element (call Position first). Use Spacing consts (including SPX/S0) so the offset flows from the same scale as padding/margin.
func (ClassList) TopOffset ¶ added in v0.2.3
func (cl ClassList) TopOffset(v PositionOffset) ClassList
func (ClassList) Transform ¶
Transform opts the element into Tailwind's transform utility surface. Required when applying translate/rotate/scale via utility classes in Tailwind v2-compatible output.
func (ClassList) Transition ¶
func (cl ClassList) Transition(t Transition) ClassList
Transition applies a transition property group.
func (ClassList) TranslateX ¶
TranslateX applies a horizontal translate via the Translate enum.
func (ClassList) TranslateXRaw ¶
TranslateXRaw / TranslateYRaw emit a raw-suffixed translate value for non-Spacing offsets like "1/2" (center-offset idiom).
func (ClassList) TranslateXStep ¶
TranslateXStep applies a horizontal translate using the Spacing scale (e.g., tw.S5 → "translate-x-5"). Use this when the offset lines up with the platform spacing scale; use TranslateX for negative/fractional offsets outside the scale.
func (ClassList) TranslateY ¶
TranslateY applies a vertical translate via the Translate enum (handles negative offsets like TranslateNeg05).
func (ClassList) TranslateYRaw ¶
func (ClassList) TranslateYStep ¶
TranslateYStep — vertical equivalent of TranslateXStep.
func (ClassList) UnderlineOffset ¶
UnderlineOffset sets the underline offset (Tailwind's "underline-offset-N"). Use the Spacing const names (S4, S8) for semantic offsets, or supply a raw numeric step if the design uses a non-standard value.
func (ClassList) Uppercase ¶
Uppercase / Lowercase / Capitalize / NormalCase set text-transform. NormalCase is the default text-transform (no transform) and is required when a base class carries uppercase/lowercase/capitalize and a specific slot wants to reset to the element's natural case.
func (ClassList) UserSelect ¶
UserSelect applies a user-select style.
func (ClassList) WhitespaceNowrap ¶
WhitespaceNowrap prevents text wrapping.
func (ClassList) WhitespacePreWrap ¶
WhitespacePreWrap preserves user whitespace and wraps long lines — Tailwind's "whitespace-pre-wrap" utility. Used by transcript and console bubbles that render AI output with embedded newlines.
func (ClassList) WidthRaw ¶
WidthRaw applies a raw width value such as "[80px]" — an arbitrary pixel/rem width outside the Spacing scale.
type Color ¶
type Color string
Color is a typed semantic color role. Values serialize to the semantic token name (e.g., "surface-primary"), not a Tailwind class fragment. The ClassList builder combines a Color with its role (background, text, border, ring) to produce the final Tailwind class.
const ( SurfacePrimary Color = "surface-primary" SurfaceSecondary Color = "surface-secondary" SurfaceTertiary Color = "surface-tertiary" SurfaceBrand Color = "surface-brand" SurfaceBrandHover Color = "surface-brand-hover" SurfaceBrandSoft Color = "surface-brand-soft" SurfaceSuccess Color = "surface-success" SurfaceSuccessSoft Color = "surface-success-soft" SurfaceWarning Color = "surface-warning" SurfaceWarningSoft Color = "surface-warning-soft" SurfaceDanger Color = "surface-danger" SurfaceDangerSoft Color = "surface-danger-soft" SurfaceInfo Color = "surface-info" SurfaceInfoSoft Color = "surface-info-soft" SurfaceDisabled Color = "surface-disabled" SurfaceHover Color = "surface-hover" SurfaceActive Color = "surface-active" SurfaceOverlay Color = "surface-overlay" SurfaceInverse Color = "surface-inverse" )
Surface colors — backgrounds and filled surfaces.
const ( FgPrimary Color = "fg-primary" FgSecondary Color = "fg-secondary" FgTertiary Color = "fg-tertiary" FgMuted Color = "fg-muted" FgPlaceholder Color = "fg-placeholder" FgBrand Color = "fg-brand" FgOnBrand Color = "fg-on-brand" FgSuccess Color = "fg-success" FgWarning Color = "fg-warning" FgDanger Color = "fg-danger" FgInfo Color = "fg-info" FgDisabled Color = "fg-disabled" FgOnSurface Color = "fg-on-surface" FgOnInverse Color = "fg-on-inverse" FgLink Color = "fg-link" FgLinkHover Color = "fg-link-hover" )
Foreground colors — text and icons.
const ( BorderPrimary Color = "border-primary" BorderSecondary Color = "border-secondary" BorderBrand Color = "border-brand" BorderSuccess Color = "border-success" BorderWarning Color = "border-warning" BorderDanger Color = "border-danger" BorderInfo Color = "border-info" )
Border colors — divider lines and outlines.
const ( RingBrand Color = "ring-brand" RingFocus Color = "ring-focus" RingDanger Color = "ring-danger" )
Ring colors — focus ring and highlights.
ColorWhite / ColorBlack are Tailwind's plain neutral colors. Prefer the semantic Fg/Surface family; use these only for hard-coded contrast cases like a button's fill-on-brand text.
const ColorTransparent Color = "transparent"
ColorSpecialTransparent is a sentinel for `transparent` backgrounds. Used when a variant needs to explicitly disable a color slot (e.g., ghost/link buttons have transparent backgrounds). It compiles to "bg-transparent", "text-transparent", etc. depending on role.
func AllColors ¶
func AllColors() []Color
AllColors returns every semantic color const in stable order. Used by the typed tables and All* enumerators to validate compile-table coverage.
type Cursor ¶
type Cursor string
Cursor is a typed cursor style.
const ( CursorAuto Cursor = "auto" CursorDefault Cursor = "default" CursorPointer Cursor = "pointer" CursorWait Cursor = "wait" CursorText Cursor = "text" CursorMove Cursor = "move" CursorHelp Cursor = "help" CursorNotAllowed Cursor = "not-allowed" CursorProgress Cursor = "progress" CursorCrosshair Cursor = "crosshair" CursorGrab Cursor = "grab" CursorGrabbing Cursor = "grabbing" )
type Display ¶
type Display string
Display is a typed CSS display mode.
const ( DisplayBlock Display = "block" DisplayInline Display = "inline" DisplayInlineBlock Display = "inline-block" DisplayFlex Display = "flex" DisplayInlineFlex Display = "inline-flex" DisplayGrid Display = "grid" DisplayInlineGrid Display = "inline-grid" DisplayHidden Display = "hidden" // DisplayContents makes the element invisible to layout while its // children remain positioned as if they were the element's // siblings (CSS `display: contents`). Used by pass-through // wrappers such as the tooltip's trigger slot. DisplayContents Display = "contents" // Table display modes — used by responsive-table components to // swap between stacked mobile view and tabular desktop view. DisplayTable Display = "table" DisplayInlineTable Display = "inline-table" DisplayTableCaption Display = "table-caption" DisplayTableCell Display = "table-cell" DisplayTableColumn Display = "table-column" DisplayTableColumnGroup Display = "table-column-group" DisplayTableHeaderGroup Display = "table-header-group" DisplayTableRow Display = "table-row" DisplayTableRowGroup Display = "table-row-group" DisplayFlowRoot Display = "flow-root" DisplayListItem Display = "list-item" )
func AllDisplays ¶
func AllDisplays() []Display
AllDisplays returns every Display const in stable order.
type Duration ¶
type Duration string
Duration is a typed transition duration step.
func AllDurations ¶
func AllDurations() []Duration
AllDurations returns every Duration const in stable order.
type FlexDir ¶
type FlexDir string
FlexDir is a typed flex-direction.
func AllFlexDirs ¶
func AllFlexDirs() []FlexDir
AllFlexDirs returns every FlexDir const in stable order.
type FontFamily ¶
type FontFamily string
FontFamily is a typed font-family utility (Tailwind's font-sans / font-serif / font-mono).
const ( FontSans FontFamily = "sans" FontSerif FontFamily = "serif" FontMono FontFamily = "mono" )
func AllFontFamilies ¶
func AllFontFamilies() []FontFamily
AllFontFamilies returns every FontFamily const in stable order.
type FontSize ¶
type FontSize string
FontSize is a typed type-scale level matching tokens.TypographyScale.
const ( TextXS FontSize = "xs" TextSM FontSize = "sm" TextBase FontSize = "base" TextLG FontSize = "lg" TextXL FontSize = "xl" Text2XL FontSize = "2xl" Text3XL FontSize = "3xl" Text4XL FontSize = "4xl" Text5XL FontSize = "5xl" Text6XL FontSize = "6xl" Text7XL FontSize = "7xl" Text8XL FontSize = "8xl" Text9XL FontSize = "9xl" )
func AllFontSizes ¶
func AllFontSizes() []FontSize
AllFontSizes returns every FontSize const in stable order.
type FontWeight ¶
type FontWeight string
FontWeight is a typed font-weight step.
const ( FontThin FontWeight = "thin" // 100 FontExtralight FontWeight = "extralight" // 200 FontLight FontWeight = "light" // 300 FontNormal FontWeight = "normal" // 400 FontMedium FontWeight = "medium" // 500 FontSemibold FontWeight = "semibold" // 600 FontBold FontWeight = "bold" // 700 FontExtrabold FontWeight = "extrabold" // 800 FontBlack FontWeight = "black" // 900 )
func AllFontWeights ¶
func AllFontWeights() []FontWeight
AllFontWeights returns every FontWeight const in stable order.
type Justify ¶
type Justify string
Justify maps to justify-content.
func AllJustify ¶
func AllJustify() []Justify
AllJustify returns every Justify const in stable order.
type Leading ¶
type Leading string
Leading is a typed line-height step.
func AllLeadings ¶
func AllLeadings() []Leading
AllLeadings returns every Leading const in stable order.
type MaxWidth ¶
type MaxWidth string
MaxWidth is a typed handle for Tailwind's named max-width scale. Values serialize to the Tailwind key ("sm", "2xl", "full") and flow through classes.MaxW to produce the "max-w-<key>" utility.
const ( MaxWXS MaxWidth = "xs" MaxWSM MaxWidth = "sm" MaxWMD MaxWidth = "md" MaxWLG MaxWidth = "lg" MaxWXL MaxWidth = "xl" MaxW2XL MaxWidth = "2xl" MaxW3XL MaxWidth = "3xl" MaxW4XL MaxWidth = "4xl" MaxW5XL MaxWidth = "5xl" MaxW6XL MaxWidth = "6xl" MaxW7XL MaxWidth = "7xl" MaxWFull MaxWidth = "full" MaxWNone MaxWidth = "none" MaxWScreen MaxWidth = "screen" MaxWProse MaxWidth = "prose" )
type Opacity ¶
type Opacity string
Opacity is a typed opacity percentage step.
const ( Opacity0 Opacity = "0" Opacity5 Opacity = "5" Opacity10 Opacity = "10" Opacity20 Opacity = "20" Opacity25 Opacity = "25" Opacity30 Opacity = "30" Opacity40 Opacity = "40" Opacity50 Opacity = "50" Opacity60 Opacity = "60" Opacity70 Opacity = "70" Opacity75 Opacity = "75" Opacity80 Opacity = "80" Opacity90 Opacity = "90" Opacity95 Opacity = "95" Opacity100 Opacity = "100" )
func AllOpacities ¶
func AllOpacities() []Opacity
AllOpacities returns every Opacity in stable order.
type Overflow ¶
type Overflow string
Overflow is a typed overflow style.
func AllOverflows ¶
func AllOverflows() []Overflow
AllOverflows returns every Overflow in stable order.
type PlatformKitClass ¶
type PlatformKitClass string
PlatformKitClass is a typed handle for application-specific or custom CSS classes that live outside Tailwind's utility namespace. Typical uses: your own design-system primitives, component handles (data-controller targets, htmx attributes surfaced as classes), progress/keyframe animations, or admin-shell chrome defined in a separate stylesheet. The values are emitted verbatim by the PK method; no "tw-" rewriting is applied.
const ( // Motion primitives (shared across multiple components). PKTransitionStandard PlatformKitClass = "pk-transition-standard" PKTransitionColors PlatformKitClass = "pk-transition-colors" PKTransitionOpacity PlatformKitClass = "pk-transition-opacity" PKTransitionProgress PlatformKitClass = "pk-transition-progress" // PKTransitionTransform is the transform-tier transition treatment // used by disclosure chevrons and other geometry-only transitions. PKTransitionTransform PlatformKitClass = "pk-transition-transform" // PKTransitionEmphasis is the emphasis-tier transition treatment // used by modal / editor surfaces that require a more pronounced // motion curve. PKTransitionEmphasis PlatformKitClass = "pk-transition-emphasis" // PKMotionModerate tunes the motion intensity for components that // want a "moderate" animation setting without re-declaring the // transition property group. PKMotionModerate PlatformKitClass = "pk-motion-moderate" // PKMotionSlow pairs with PKMotionModerate — used by page-level // progress surfaces (wizards, long-running flows) where the // animation curve should feel gentler than the default. PKMotionSlow PlatformKitClass = "pk-motion-slow" // Progress-bar animations. PKProgressFill PlatformKitClass = "pk-progress-fill" PKProgressFillIndeterminate PlatformKitClass = "pk-progress-fill-indeterminate" AnimatePKProgressBar PlatformKitClass = "animate-pk-progress-bar" // Component handles (data-attribute selectors used by HTMX / // Stimulus controllers and by custom stylesheets). PKHandleChatFab PlatformKitClass = "chat-fab" // Example admin / shell handles. These demonstrate the pattern // for routing non-Tailwind class names through the typed builder. PKAdminSidebarShell PlatformKitClass = "admin-sidebar-shell" PKAdminSidebarBrand PlatformKitClass = "admin-sidebar-brand" PKAdminSidebarBrandMark PlatformKitClass = "admin-sidebar-brand-mark" PKAdminSidebarBrandCopy PlatformKitClass = "admin-sidebar-brand-copy" PKAdminSidebarBrandEyebrow PlatformKitClass = "admin-sidebar-brand-eyebrow" PKAdminSidebarBrandTitle PlatformKitClass = "admin-sidebar-brand-title" PKAdminSidebarBrandText PlatformKitClass = "admin-sidebar-brand-text" PKAdminSidebarChevron PlatformKitClass = "admin-sidebar-chevron" PKAdminSidebarSectionTitle PlatformKitClass = "admin-sidebar-section-title" PKAdminSidebarLink PlatformKitClass = "admin-sidebar-link" PKAdminSidebarDock PlatformKitClass = "admin-sidebar-dock" PKAdminSidebarTenantSwitch PlatformKitClass = "admin-sidebar-tenant-switcher" PKAdminSidebarTenantLabel PlatformKitClass = "admin-sidebar-tenant-label" PKAdminSidebarUserMenu PlatformKitClass = "admin-sidebar-user-menu" PKAdminTopbar PlatformKitClass = "admin-topbar" PKAdminTopbarShell PlatformKitClass = "admin-topbar-shell" PKAdminTopbarContext PlatformKitClass = "admin-topbar-context" PKAdminTopbarKicker PlatformKitClass = "admin-topbar-kicker" PKAdminTopbarHeading PlatformKitClass = "admin-topbar-heading" PKAdminTopbarTitle PlatformKitClass = "admin-topbar-title" PKAdminTopbarBadge PlatformKitClass = "admin-topbar-badge" PKAdminTopbarSubtitle PlatformKitClass = "admin-topbar-subtitle" PKAdminTopbarActions PlatformKitClass = "admin-topbar-actions" PKAdminTopbarTenantSwitch PlatformKitClass = "admin-topbar-tenant-switcher" PKAdminTopbarTenantLabel PlatformKitClass = "admin-topbar-tenant-label" PKAdminTopbarNotifications PlatformKitClass = "admin-topbar-notifications" PKAdminTopbarUserMenu PlatformKitClass = "admin-topbar-user-menu" PKAdminTopbarThemeToggle PlatformKitClass = "admin-topbar-theme-toggle" PKAdminToolbarSearch PlatformKitClass = "admin-toolbar-search" PKAdminToolbarShortcut PlatformKitClass = "admin-toolbar-shortcut" // State-attribute classes (is-active, is-idle, is-parent, is-open). // They are not Tailwind utilities; include them when your CSS // responds to these state markers. PKStateActive PlatformKitClass = "is-active" PKStateIdle PlatformKitClass = "is-idle" PKStateParent PlatformKitClass = "is-parent" PKStateOpen PlatformKitClass = "is-open" )
Example non-Tailwind classes. Consumers are expected to define their own values (or alias these) that match classes present in their CSS bundles. The names and values here are retained for compatibility with existing call sites; new consumers should introduce their own typed constants of this type.
func AllPlatformKitClasses ¶
func AllPlatformKitClasses() []PlatformKitClass
AllPlatformKitClasses returns every PlatformKitClass const in stable order. Useful for exhaustive coverage tests of the escape-hatch path.
type PointerEvents ¶
type PointerEvents string
PointerEvents is a typed pointer-events style.
const ( PointerAuto PointerEvents = "auto" PointerNone PointerEvents = "none" )
func AllPointerEvents ¶
func AllPointerEvents() []PointerEvents
AllPointerEvents returns every PointerEvents in stable order.
type Position ¶
type Position string
Position is a typed CSS position.
func AllPositions ¶
func AllPositions() []Position
AllPositions returns every Position const in stable order.
type PositionOffset ¶ added in v0.2.3
type PositionOffset string
PositionOffset is a non-spacing positional fraction used to anchor overlays. It is separate from Spacing so values such as 1/2 cannot leak into padding, gap, or size utilities.
const (
PositionHalf PositionOffset = "1/2"
)
func AllPositionOffsets ¶ added in v0.2.3
func AllPositionOffsets() []PositionOffset
AllPositionOffsets returns every governed overlay-position fraction.
type Radius ¶
type Radius string
Radius is a typed border-radius step matching tokens.RadiusScale.
type ResizeMode ¶
type ResizeMode string
ResizeMode is a typed textarea resize mode.
const ( ResizeModeNone ResizeMode = "none" ResizeModeY ResizeMode = "y" ResizeModeX ResizeMode = "x" ResizeModeBoth ResizeMode = "both" )
func AllResizeModes ¶
func AllResizeModes() []ResizeMode
AllResizeModes returns every ResizeMode in stable order.
type RingOffset ¶
type RingOffset string
RingOffset is a typed ring-offset thickness step.
const ( RingOffset0 RingOffset = "0" RingOffset1 RingOffset = "1" RingOffset2 RingOffset = "2" RingOffset4 RingOffset = "4" RingOffset8 RingOffset = "8" )
func AllRingOffsets ¶
func AllRingOffsets() []RingOffset
AllRingOffsets returns every RingOffset in stable order.
type RingWidth ¶
type RingWidth string
RingWidth is a typed focus-ring thickness step.
func AllRingWidths ¶
func AllRingWidths() []RingWidth
AllRingWidths returns every RingWidth in stable order.
type Shadow ¶
type Shadow string
Shadow is a typed box-shadow step matching tokens.ShadowScale.
type Shape ¶
type Shape string
Shape is a typed component shape. Values match the canonical keys in base.Component shape semantics.
type Size ¶
type Size string
Size is a typed component size step. Values match the canonical keys in ButtonTokens.Sizes, InputTokens.Sizes, and other SizeMap consumers.
type Spacing ¶
type Spacing string
Spacing is a typed spacing step matching tokens.SpacingScale entries. Values serialize to the Tailwind spacing key (e.g., "3.5", "4", "px"), not to a complete utility class. The ClassList builder combines a Spacing with its role (padding, margin, width, height, gap) to produce the final Tailwind class.
const ( SPX Spacing = "px" // 1px S0 Spacing = "0" // 0rem S0_5 Spacing = "0.5" // 0.125rem S1 Spacing = "1" // 0.25rem S1_5 Spacing = "1.5" // 0.375rem S2 Spacing = "2" // 0.5rem S2_5 Spacing = "2.5" // 0.625rem S3 Spacing = "3" // 0.75rem S3_5 Spacing = "3.5" // 0.875rem S4 Spacing = "4" // 1rem S5 Spacing = "5" // 1.25rem S6 Spacing = "6" // 1.5rem S7 Spacing = "7" // 1.75rem S8 Spacing = "8" // 2rem S9 Spacing = "9" // 2.25rem S10 Spacing = "10" // 2.5rem S11 Spacing = "11" // 2.75rem S12 Spacing = "12" // 3rem S14 Spacing = "14" // 3.5rem S16 Spacing = "16" // 4rem S20 Spacing = "20" // 5rem S24 Spacing = "24" // 6rem S28 Spacing = "28" // 7rem S32 Spacing = "32" // 8rem S36 Spacing = "36" // 9rem S40 Spacing = "40" // 10rem S44 Spacing = "44" // 11rem S48 Spacing = "48" // 12rem S52 Spacing = "52" // 13rem S56 Spacing = "56" // 14rem S60 Spacing = "60" // 15rem S64 Spacing = "64" // 16rem S72 Spacing = "72" // 18rem S80 Spacing = "80" // 20rem S96 Spacing = "96" // 24rem SAuto Spacing = "auto" // auto SFull Spacing = "full" // 100% (width/height only) )
Spacing steps — names align with tokens.SpacingScale and the Tailwind default spacing scale. Fractional values use underscore for the decimal point in the Go const name (S0_5 → "0.5").
func AllSpacings ¶
func AllSpacings() []Spacing
AllSpacings returns every Spacing const in stable order. Used by the typed tables and All* enumerators to validate compile-table coverage.
type State ¶
type State string
State is a typed CSS modifier state (hover, focus, disabled, etc.). Used with ClassList.On() to wrap child classes in a Tailwind prefix such as "hover:" or "focus-visible:".
const ( StateHover State = "hover" StateFocus State = "focus" StateFocusVisible State = "focus-visible" StateFocusWithin State = "focus-within" StateActive State = "active" StateDisabled State = "disabled" StateChecked State = "checked" StateFirst State = "first" StateLast State = "last" StateOdd State = "odd" StateEven State = "even" StateGroupHover State = "group-hover" StateGroupFocus State = "group-focus" StatePeer State = "peer" StatePlaceholder State = "placeholder" StateDark State = "dark" )
Canonical state modifiers.
type TextAlign ¶
type TextAlign string
TextAlign is a typed text alignment.
func AllTextAligns ¶
func AllTextAligns() []TextAlign
AllTextAligns returns every TextAlign const in stable order.
type Tracking ¶
type Tracking string
Tracking is a typed letter-spacing step.
func AllTrackings ¶
func AllTrackings() []Tracking
AllTrackings returns every Tracking const in stable order.
type Transition ¶
type Transition string
Transition is a typed CSS transition property group.
const ( TransitionNone Transition = "none" TransitionAll Transition = "all" TransitionColors Transition = "colors" TransitionOpacity Transition = "opacity" TransitionShadow Transition = "shadow" TransitionTransform Transition = "transform" )
func AllTransitions ¶
func AllTransitions() []Transition
AllTransitions returns every Transition const in stable order.
type Translate ¶
type Translate string
Translate is a typed translate step (for hover lifts etc.).
const ( TranslateNone Translate = "0" TranslatePx Translate = "px" Translate0_5 Translate = "0.5" TranslateHalf Translate = "1/2" Translate1 Translate = "1" TranslateNeg05 Translate = "neg-0.5" // -translate-y-0.5 TranslateNegHalf Translate = "neg-1/2" TranslateNeg1 Translate = "neg-1" TranslateNeg2 Translate = "neg-2" )
func AllTranslates ¶
func AllTranslates() []Translate
AllTranslates returns every Translate in stable order.
type Variant ¶
type Variant string
Variant is a typed component visual variant. Component builders accept this type — not raw strings — as the variant input.
Values serialize to the canonical variant name (e.g., "primary") used across the design manifest, Storybook stories, and CSS class resolution maps. The design system's VariantMap type is keyed on string for Go-ergonomic lookup; callers should use variant.String() when interacting with those maps.
const ( VariantDefault Variant = "default" VariantPrimary Variant = "primary" VariantSecondary Variant = "secondary" VariantSuccess Variant = "success" VariantWarning Variant = "warning" VariantError Variant = "error" VariantDanger Variant = "danger" // alias of VariantError for domain code that prefers "danger" VariantInfo Variant = "info" VariantOutline Variant = "outline" VariantGhost Variant = "ghost" VariantLink Variant = "link" )
Canonical variant names. Match the keys used in ButtonTokens.Variants, BadgeTokens.Variants, and other VariantMap consumers.
func AllVariants ¶
func AllVariants() []Variant
AllVariants returns every canonical Variant in stable order.
type ViewportHeight ¶ added in v0.2.4
type ViewportHeight string
ViewportHeight is the closed set of viewport-relative heights used by governed overlays. Keeping these values typed lets CSS emission remain fail-closed while supporting responsive drawers and sheets.
const ( VH25 ViewportHeight = "25" VH50 ViewportHeight = "50" VH75 ViewportHeight = "75" VH85 ViewportHeight = "85" VH100 ViewportHeight = "100" )
func AllViewportHeights ¶ added in v0.2.4
func AllViewportHeights() []ViewportHeight
AllViewportHeights returns every supported viewport height in stable order.
type ZLayer ¶
type ZLayer int16
ZLayer is a typed semantic z-index layer. The underlying value is the numeric z-index used across the design system (see tokens.ZIndexScale). The Class() method converts a ZLayer to its Tailwind arbitrary-value class (e.g., ZModal → "z-[1400]"), so there is no "magic z-50 vs z-70" — every layer's number comes from the typed tokens.
const ( ZBelow ZLayer = -10 ZBase ZLayer = 0 ZDocked ZLayer = 10 ZDropdown ZLayer = 1000 ZSticky ZLayer = 1100 ZBanner ZLayer = 1200 ZOverlay ZLayer = 1300 ZModal ZLayer = 1400 ZPopover ZLayer = 1500 ZToast ZLayer = 1600 ZTooltip ZLayer = 1700 )
Semantic z-index layers. Numeric values match tokens.DefaultZIndex and are the single source of truth. Changing the value here is the only place a z-index number should ever appear.
func (ZLayer) Class ¶
Class returns the Tailwind arbitrary-value z-index class. For negative layers, emits "-z-[N]"; for positive, "z-[N]".