tw

package module
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

README

tw

Typed builder for Tailwind utility class strings.

Package tw exports a small immutable fluent builder (ClassList) and a complete set of typed constants covering Tailwind's layout, spacing, sizing, color roles, typography, border, shadow, motion, state, breakpoint, z-index, and related utilities.

import "github.com/septagon-oss/tw"

button := tw.New().
    Display(tw.DisplayInlineFlex).
    Items(tw.ItemsCenter).
    Justify(tw.JustifyCenter).
    Gap(tw.S2).
    PaddingX(tw.S4).
    PaddingY(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)
    }).
    Transition(tw.TransitionColors, tw.Duration200).
    Compile()

Compile() walks the accumulated segments once and returns a deterministic space-separated string suitable for gomponents, templ, or any HTML attribute writer. The builder allocates only on mutation; zero-value and empty compile to "".

All semantic colors (Surface*, Fg*, Border*, Ring*) are first-class; role methods (Bg, TextColor, BorderColor, RingColor) map them to the correct "bg-"/"text-"/... utility. Specials such as ColorTransparent and the plain ColorWhite/ColorBlack are supported.

Spacing, Radius, Shadow, Font*, Tracking, etc. follow the same pattern: pass the typed step to the role method.

Prefixing:

  • On(state, func(ClassList) ClassList) wraps the inner result with "hover:", "focus-visible:", "group-hover:", etc. Nesting supported.
  • Breakpoint(bp, func...) does the same for "sm:", "lg:", ...

Composition:

  • Merge(other) appends another builder's segments.
  • Raw(s) passes a pre-validated utility string through (use for runtime values or migration only).

Non-Tailwind classes (custom CSS, component handles, your animation keyframes, custom component handles, or other app-specific markers) are routed through the PlatformKitClass type and the PK(c) method so they bypass any Tailwind-only linters.

Enumerators (AllColors, AllStates, AllRadii, AllZLayers, ...) exist for exhaustive testing and coverage tooling.

See godoc for the complete method and constant set. The package has comprehensive tests and executable Examples.

The package is used as the single source of Tailwind class construction for component libraries and is intended to be generally useful anywhere a typed, zero-static-string Tailwind DSL is desired in Go.

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

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).

func (Breakpoint) String

func (b Breakpoint) String() string

String returns the breakpoint key.

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 New

func New() ClassList

New returns an empty ClassList.

func (ClassList) Accent

func (cl ClassList) Accent(c Color) ClassList

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

func (cl ClassList) AnimatePulse() ClassList

AnimatePulse applies Tailwind's "animate-pulse" utility.

func (ClassList) AnimateSpin

func (cl ClassList) AnimateSpin() ClassList

AnimateSpin applies Tailwind's "animate-spin" utility.

func (ClassList) AppearanceNone

func (cl ClassList) AppearanceNone() ClassList

AppearanceNone removes native OS chrome from form controls.

func (ClassList) AspectRaw

func (cl ClassList) AspectRaw(raw string) ClassList

AspectRaw applies an arbitrary-value aspect ratio, e.g. "4/3" → "aspect-4/3". Prefer AspectVideo()/AspectSquare() when they match.

func (ClassList) AspectSquare

func (cl ClassList) AspectSquare() ClassList

AspectSquare / AspectVideo set aspect-ratio.

func (ClassList) AspectVideo

func (cl ClassList) AspectVideo() ClassList

func (ClassList) BackdropBlur

func (cl ClassList) BackdropBlur(size string) ClassList

BackdropBlur applies a backdrop-blur utility.

func (ClassList) Bg

func (cl ClassList) Bg(c Color) ClassList

Bg applies a background color.

func (ClassList) BgOpacity

func (cl ClassList) BgOpacity(c Color, opacity string) ClassList

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 (cl ClassList) BorderBottomColor(c Color) ClassList

func (ClassList) BorderColor

func (cl ClassList) BorderColor(c Color) ClassList

BorderColor applies a border color.

func (ClassList) BorderColorOpacity

func (cl ClassList) BorderColorOpacity(c Color, opacity string) ClassList

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 (cl ClassList) BorderLeftColor(c Color) ClassList

func (ClassList) BorderRight

func (cl ClassList) BorderRight(b BorderWidth) ClassList

func (ClassList) BorderRightColor

func (cl ClassList) BorderRightColor(c Color) ClassList

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

func (cl ClassList) BorderTopColor(c Color) ClassList

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) Bottom

func (cl ClassList) Bottom(s Spacing) ClassList

func (ClassList) BottomOffset added in v0.2.3

func (cl ClassList) BottomOffset(v PositionOffset) ClassList

func (ClassList) BottomRaw

func (cl ClassList) BottomRaw(v string) ClassList

func (ClassList) BreakAll

func (cl ClassList) BreakAll() ClassList

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

func (cl ClassList) BreakWords() ClassList

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 (cl ClassList) Capitalize() ClassList

func (ClassList) ColSpan

func (cl ClassList) ColSpan(n int) ClassList

ColSpan applies a CSS grid column span ("col-span-N"). N must be positive; 0 or negative → empty.

func (ClassList) ColSpanFull

func (cl ClassList) ColSpanFull() ClassList

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

func (cl ClassList) Compile() string

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

func (cl ClassList) Container() ClassList

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) Cursor

func (cl ClassList) Cursor(c Cursor) ClassList

Cursor applies a cursor style.

func (ClassList) Display

func (cl ClassList) Display(d Display) ClassList

Display sets the CSS display mode (flex, grid, block, etc.).

func (ClassList) DivideX

func (cl ClassList) DivideX(s Spacing) ClassList

DivideX / DivideY add borders between adjacent children. Pass empty Spacing for default; pass a Spacing const for a specific width.

func (ClassList) DivideY

func (cl ClassList) DivideY(s Spacing) ClassList

func (ClassList) Duration

func (cl ClassList) Duration(d Duration) ClassList

Duration applies a transition duration.

func (ClassList) Easing

func (cl ClassList) Easing(e Easing) ClassList

Easing applies a transition easing curve.

func (ClassList) Flex1

func (cl ClassList) Flex1() ClassList

Flex1 makes a flex child fill available space — Tailwind's "flex-1".

func (ClassList) FlexDir

func (cl ClassList) FlexDir(f FlexDir) ClassList

FlexDir sets flex-direction.

func (ClassList) FlexGrow

func (cl ClassList) FlexGrow() ClassList

func (ClassList) FlexGrow0

func (cl ClassList) FlexGrow0() ClassList

func (ClassList) FlexNoWrap

func (cl ClassList) FlexNoWrap() ClassList

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

func (cl ClassList) FlexNone() ClassList

FlexGrow / FlexGrow0 toggle the flex-grow property. FlexNone prevents a flex child from growing or shrinking — Tailwind's "flex-none" utility.

func (ClassList) FlexShrink0

func (cl ClassList) FlexShrink0() ClassList

FlexShrink0 prevents a flex child from shrinking below its intrinsic size — Tailwind's "flex-shrink-0" utility.

func (ClassList) FlexWrap

func (cl ClassList) FlexWrap() ClassList

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) FontSize

func (cl ClassList) FontSize(f FontSize) ClassList

FontSize applies a text-size step.

func (ClassList) FontWeight

func (cl ClassList) FontWeight(f FontWeight) ClassList

FontWeight applies a font-weight.

func (ClassList) Gap

func (cl ClassList) Gap(s Spacing) ClassList

Gap sets flex/grid gap.

func (ClassList) GapX

func (cl ClassList) GapX(s Spacing) ClassList

GapX / GapY set axis-specific flex/grid gaps (gap-x-*, gap-y-*).

func (ClassList) GapY

func (cl ClassList) GapY(s Spacing) ClassList

func (ClassList) GridCols

func (cl ClassList) GridCols(n int) ClassList

GridCols applies a CSS grid template with N equally-sized columns ("grid-cols-N"). Use together with Display(DisplayGrid).

func (ClassList) GridColsRaw

func (cl ClassList) GridColsRaw(raw string) ClassList

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

func (cl ClassList) Group() ClassList

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) Height

func (cl ClassList) Height(s Spacing) ClassList

Height sets height.

func (ClassList) HeightRaw

func (cl ClassList) HeightRaw(v string) ClassList

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) Inset

func (cl ClassList) Inset(s Spacing) ClassList

Inset applies an offset to all four sides.

func (ClassList) InsetX

func (cl ClassList) InsetX(s Spacing) ClassList

InsetX / InsetY apply to horizontal / vertical pairs.

func (ClassList) InsetY

func (cl ClassList) InsetY(s Spacing) ClassList

func (ClassList) IsEmpty

func (cl ClassList) IsEmpty() bool

IsEmpty reports whether the builder has no segments.

func (ClassList) Italic

func (cl ClassList) Italic() ClassList

Italic / NotItalic set font-style.

func (ClassList) Items

func (cl ClassList) Items(i Items) ClassList

Items sets align-items.

func (ClassList) Justify

func (cl ClassList) Justify(j Justify) ClassList

Justify sets justify-content.

func (ClassList) Leading

func (cl ClassList) Leading(l Leading) ClassList

Leading applies a line-height step.

func (ClassList) Left

func (cl ClassList) Left(s Spacing) ClassList

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

func (cl ClassList) LeftRaw(v string) ClassList

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

func (cl ClassList) Len() int

Len returns the number of segments currently in the builder. Exposed for tests — do not rely on it for runtime logic.

func (ClassList) LineClamp

func (cl ClassList) LineClamp(n int) ClassList

LineClamp truncates a paragraph after N lines (Tailwind's "line-clamp-N"). Use N >= 1; N == 0 emits "line-clamp-none".

func (ClassList) LineThrough

func (cl ClassList) LineThrough() ClassList

LineThrough / NotLineThrough set the line-through text-decoration.

func (ClassList) ListStyle

func (cl ClassList) ListStyle(style string) ClassList

ListStyle sets list-style-type (decimal/disc/none).

func (ClassList) Lowercase

func (cl ClassList) Lowercase() ClassList

func (ClassList) Margin

func (cl ClassList) Margin(s Spacing) ClassList

Margin sets margin on all sides.

func (ClassList) MarginBottom

func (cl ClassList) MarginBottom(s Spacing) ClassList

func (ClassList) MarginLeft

func (cl ClassList) MarginLeft(s Spacing) ClassList

MarginLeft / MarginRight / MarginTop / MarginBottom — per-side margin.

func (ClassList) MarginRight

func (cl ClassList) MarginRight(s Spacing) ClassList

func (ClassList) MarginTop

func (cl ClassList) MarginTop(s Spacing) ClassList

func (ClassList) MarginX

func (cl ClassList) MarginX(s Spacing) ClassList

MarginX sets horizontal margin.

func (ClassList) MarginY

func (cl ClassList) MarginY(s Spacing) ClassList

MarginY sets vertical margin.

func (ClassList) MaxH

func (cl ClassList) MaxH(v string) ClassList

MaxH sets max-height. Same value space as MinH.

func (ClassList) MaxHeight added in v0.2.4

func (cl ClassList) MaxHeight(s Spacing) ClassList

MaxHeight sets max-height from the governed spacing scale.

func (ClassList) MaxHeightRaw

func (cl ClassList) MaxHeightRaw(v string) ClassList

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

func (cl ClassList) MaxW(name string) ClassList

MaxW sets max-width using Tailwind's named scale. Use MaxWScale for spacing-based max-widths (max-w-<step>).

func (ClassList) MaxWScaled

func (cl ClassList) MaxWScaled(name MaxWidth) ClassList

MaxWScaled applies Tailwind's named max-width scale via a typed handle. Distinct from MaxW which takes an untyped string.

func (ClassList) MaxWidthRaw

func (cl ClassList) MaxWidthRaw(v string) ClassList

MaxWidthRaw applies a raw max-width value such as "[30rem]" or "[80px]" — for arbitrary pixel/rem widths outside the named MaxWidth scale.

func (ClassList) Merge

func (cl ClassList) Merge(other ClassList) ClassList

Merge appends another ClassList to this one.

func (ClassList) MinH

func (cl ClassList) MinH(v string) ClassList

MinH sets min-height. Accepts Spacing const names plus special values like "screen" / "full".

func (ClassList) MinHeight

func (cl ClassList) MinHeight(s Spacing) ClassList

MinHeight sets min-height.

func (ClassList) MinHeightRaw

func (cl ClassList) MinHeightRaw(v string) ClassList

MinHeightRaw applies a raw min-height value such as "[6rem]". Reserved for arbitrary-value utilities outside the Spacing scale.

func (ClassList) MinWidth

func (cl ClassList) MinWidth(s Spacing) ClassList

MinWidth sets min-width.

func (ClassList) MinWidthRaw

func (cl ClassList) MinWidthRaw(v string) ClassList

MinWidthRaw applies a raw min-width value such as "[3ch]" or "0". Reserved for arbitrary-value utilities outside the Spacing scale.

func (ClassList) NegBottom

func (cl ClassList) NegBottom(s Spacing) ClassList

func (ClassList) NegLeft

func (cl ClassList) NegLeft(s Spacing) ClassList

func (ClassList) NegMargin

func (cl ClassList) NegMargin(side string, s Spacing) ClassList

NegMargin sets a negative margin on the requested side. side is one of "" (all sides), "t", "b", "l", "r", "x", "y".

func (ClassList) NegRight

func (cl ClassList) NegRight(s Spacing) ClassList

func (ClassList) NegTop

func (cl ClassList) NegTop(s Spacing) ClassList

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 (cl ClassList) NegTranslateX(raw string) ClassList

func (ClassList) NegTranslateY

func (cl ClassList) NegTranslateY(raw string) ClassList

func (ClassList) NoLineThrough

func (cl ClassList) NoLineThrough() ClassList

func (ClassList) NoUnderline

func (cl ClassList) NoUnderline() ClassList

NoUnderline removes underline text-decoration.

func (ClassList) NormalCase

func (cl ClassList) NormalCase() ClassList

func (ClassList) NotItalic

func (cl ClassList) NotItalic() ClassList

func (ClassList) ObjectContain

func (cl ClassList) ObjectContain() ClassList

ObjectContain applies Tailwind's "object-contain" utility — scales the content to fit without cropping.

func (ClassList) ObjectCover

func (cl ClassList) ObjectCover() ClassList

ObjectCover is a shorthand for ObjectFit("cover").

func (ClassList) ObjectFit

func (cl ClassList) ObjectFit(fit string) ClassList

ObjectFit sets object-fit (cover/contain/fill/none/scale-down).

func (ClassList) On

func (cl ClassList) On(state State, build func(ClassList) ClassList) ClassList

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) Opacity

func (cl ClassList) Opacity(o Opacity) ClassList

Opacity applies an opacity percentage.

func (ClassList) Origin

func (cl ClassList) Origin(side string) ClassList

Origin sets transform-origin (top-right, bottom-left, etc.).

func (ClassList) Outline

func (cl ClassList) Outline(o Outline) ClassList

Outline applies an outline style.

func (ClassList) Overflow

func (cl ClassList) Overflow(o Overflow) ClassList

Overflow sets overflow on both axes.

func (ClassList) OverflowX

func (cl ClassList) OverflowX(o Overflow) ClassList

OverflowX / OverflowY apply axis-specific overflow.

func (ClassList) OverflowY

func (cl ClassList) OverflowY(o Overflow) ClassList

func (ClassList) OverscrollContain

func (cl ClassList) OverscrollContain() ClassList

OverscrollContain sets overscroll-behavior to contain (Tailwind's "overscroll-contain"). Prevents scroll chaining out of a container.

func (ClassList) PK

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) Padding

func (cl ClassList) Padding(s Spacing) ClassList

Padding sets padding on all sides.

func (ClassList) PaddingBottom

func (cl ClassList) PaddingBottom(s Spacing) ClassList

func (ClassList) PaddingLeft

func (cl ClassList) PaddingLeft(s Spacing) ClassList

PaddingLeft / PaddingRight / PaddingTop / PaddingBottom — per-side padding.

func (ClassList) PaddingRight

func (cl ClassList) PaddingRight(s Spacing) ClassList

func (ClassList) PaddingTop

func (cl ClassList) PaddingTop(s Spacing) ClassList

func (ClassList) PaddingTopRaw

func (cl ClassList) PaddingTopRaw(v string) ClassList

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) PaddingX

func (cl ClassList) PaddingX(s Spacing) ClassList

PaddingX sets horizontal padding.

func (ClassList) PaddingY

func (cl ClassList) PaddingY(s Spacing) ClassList

PaddingY sets vertical padding.

func (ClassList) Peer

func (cl ClassList) Peer() ClassList

func (ClassList) PointerEvents

func (cl ClassList) PointerEvents(p PointerEvents) ClassList

PointerEvents applies a pointer-events style.

func (ClassList) Position

func (cl ClassList) Position(p Position) ClassList

Position sets CSS position.

func (ClassList) Raw

func (cl ClassList) Raw(classes string) ClassList

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) Relative

func (cl ClassList) Relative() ClassList

Relative is a shorthand for Position(PositionRelative).

func (ClassList) Resize

func (cl ClassList) Resize(mode ResizeMode) ClassList

Resize applies a textarea-resize mode (`none` / `y` / `x` / `both`).

func (ClassList) ResizeNone

func (cl ClassList) ResizeNone() ClassList

ResizeNone is a shorthand for Resize(ResizeModeNone): disables the textarea resize handle entirely.

func (ClassList) ResizeY

func (cl ClassList) ResizeY() ClassList

ResizeY is a shorthand for Resize(ResizeModeY): allows vertical resize only (the default for auto-grow textareas).

func (ClassList) Right

func (cl ClassList) Right(s Spacing) ClassList

func (ClassList) RightOffset added in v0.2.3

func (cl ClassList) RightOffset(v PositionOffset) ClassList

func (ClassList) RightRaw

func (cl ClassList) RightRaw(v string) ClassList

func (ClassList) Ring

func (cl ClassList) Ring(r RingWidth) ClassList

Ring applies a focus-ring width (use RingColor for the color).

func (ClassList) RingColor

func (cl ClassList) RingColor(c Color) ClassList

RingColor applies a ring color.

func (ClassList) RingInset

func (cl ClassList) RingInset() ClassList

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

func (cl ClassList) Rotate(deg string) ClassList

Rotate sets a Tailwind rotate-* transform. deg is a numeric step like "45", "90", "180" matching the Tailwind rotate scale.

func (ClassList) Rounded

func (cl ClassList) Rounded(r Radius) ClassList

Rounded applies a border-radius step. RadiusBase emits "rounded".

func (ClassList) RoundedBottom

func (cl ClassList) RoundedBottom(r Radius) ClassList

func (ClassList) RoundedLeft

func (cl ClassList) RoundedLeft(r Radius) ClassList

func (ClassList) RoundedRaw

func (cl ClassList) RoundedRaw(v string) ClassList

RoundedRaw applies a raw border-radius value such as "[20px]" — an arbitrary-value radius outside the Radius scale.

func (ClassList) RoundedRight

func (cl ClassList) RoundedRight(r Radius) ClassList

func (ClassList) RoundedTop

func (cl ClassList) RoundedTop(r Radius) ClassList

RoundedTop / RoundedBottom / RoundedLeft / RoundedRight apply a per-side border-radius step. Use Rounded(...) for all four corners.

func (ClassList) Shadow

func (cl ClassList) Shadow(s Shadow) ClassList

Shadow applies a box-shadow step. ShadowBase emits "shadow".

func (ClassList) SpaceX

func (cl ClassList) SpaceX(s Spacing) ClassList

SpaceX / SpaceY add horizontal / vertical spacing between adjacent sibling elements (Tailwind's "space-x-*" / "space-y-*").

func (ClassList) SpaceY

func (cl ClassList) SpaceY(s Spacing) ClassList

func (ClassList) SrOnly

func (cl ClassList) SrOnly() ClassList

SrOnly makes content accessible only to screen readers.

func (ClassList) TabularNums

func (cl ClassList) TabularNums() ClassList

TabularNums applies Tailwind's "tabular-nums" font-variant-numeric utility — forces fixed-width digits, used by counter displays.

func (ClassList) TextAlign

func (cl ClassList) TextAlign(t TextAlign) ClassList

TextAlign applies a text-align.

func (ClassList) TextColor

func (cl ClassList) TextColor(c Color) ClassList

TextColor applies a foreground color. (Named TextColor rather than Text to avoid collision with FontSize.)

func (ClassList) TextColorOpacity

func (cl ClassList) TextColorOpacity(c Color, opacity string) ClassList

TextColorOpacity sets a text color with an alpha modifier, e.g. TextColorOpacity(ColorWhite, "80") → "text-white/80".

func (ClassList) Top

func (cl ClassList) Top(s Spacing) ClassList

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) TopRaw

func (cl ClassList) TopRaw(v string) ClassList

func (ClassList) Tracking

func (cl ClassList) Tracking(t Tracking) ClassList

Tracking applies a letter-spacing step.

func (ClassList) Transform

func (cl ClassList) Transform() ClassList

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

func (cl ClassList) TranslateX(t Translate) ClassList

TranslateX applies a horizontal translate via the Translate enum.

func (ClassList) TranslateXRaw

func (cl ClassList) TranslateXRaw(raw string) ClassList

TranslateXRaw / TranslateYRaw emit a raw-suffixed translate value for non-Spacing offsets like "1/2" (center-offset idiom).

func (ClassList) TranslateXStep

func (cl ClassList) TranslateXStep(s Spacing) ClassList

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

func (cl ClassList) TranslateY(t Translate) ClassList

TranslateY applies a vertical translate via the Translate enum (handles negative offsets like TranslateNeg05).

func (ClassList) TranslateYRaw

func (cl ClassList) TranslateYRaw(raw string) ClassList

func (ClassList) TranslateYStep

func (cl ClassList) TranslateYStep(s Spacing) ClassList

TranslateYStep — vertical equivalent of TranslateXStep.

func (ClassList) Truncate

func (cl ClassList) Truncate() ClassList

Truncate clips overflowing text with ellipsis.

func (ClassList) Underline

func (cl ClassList) Underline() ClassList

Underline applies underline text-decoration.

func (ClassList) UnderlineOffset

func (cl ClassList) UnderlineOffset(step Spacing) ClassList

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

func (cl ClassList) Uppercase() ClassList

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

func (cl ClassList) UserSelect(s Select) ClassList

UserSelect applies a user-select style.

func (ClassList) WhitespaceNowrap

func (cl ClassList) WhitespaceNowrap() ClassList

WhitespaceNowrap prevents text wrapping.

func (ClassList) WhitespacePreWrap

func (cl ClassList) WhitespacePreWrap() ClassList

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) Width

func (cl ClassList) Width(s Spacing) ClassList

Width sets width.

func (ClassList) WidthRaw

func (cl ClassList) WidthRaw(v string) ClassList

WidthRaw applies a raw width value such as "[80px]" — an arbitrary pixel/rem width outside the Spacing scale.

func (ClassList) ZIndex

func (cl ClassList) ZIndex(z ZLayer) ClassList

ZIndex is an alias for ZLayer.

func (ClassList) ZIndexRaw

func (cl ClassList) ZIndexRaw(raw string) ClassList

ZIndexRaw applies a Tailwind z-index class using a raw suffix ("40", "50", "auto"). Reserved for components preserving legacy z-index values that do not map to the typed ZLayer enum.

func (ClassList) ZLayer

func (cl ClassList) ZLayer(z ZLayer) ClassList

ZLayer applies a typed z-index layer.

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.

const (
	ColorWhite Color = "white"
	ColorBlack Color = "black"
)

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.

func (Color) IsZero

func (c Color) IsZero() bool

IsZero reports whether the Color is the zero value.

func (Color) String

func (c Color) String() string

String returns the semantic token name.

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"
)

func AllCursors

func AllCursors() []Cursor

AllCursors returns every Cursor in stable order.

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"
	DisplayTableFooterGroup Display = "table-footer-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.

const (
	Duration75   Duration = "75"
	Duration100  Duration = "100"
	Duration150  Duration = "150"
	Duration200  Duration = "200"
	Duration300  Duration = "300"
	Duration500  Duration = "500"
	Duration700  Duration = "700"
	Duration1000 Duration = "1000"
)

func AllDurations

func AllDurations() []Duration

AllDurations returns every Duration const in stable order.

type Easing

type Easing string

Easing is a typed transition easing curve.

const (
	EaseLinear Easing = "linear"
	EaseIn     Easing = "in"
	EaseOut    Easing = "out"
	EaseInOut  Easing = "in-out"
)

func AllEasings

func AllEasings() []Easing

AllEasings returns every Easing const in stable order.

type FlexDir

type FlexDir string

FlexDir is a typed flex-direction.

const (
	FlexRow        FlexDir = "row"
	FlexRowReverse FlexDir = "row-reverse"
	FlexCol        FlexDir = "col"
	FlexColReverse FlexDir = "col-reverse"
)

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 Items

type Items string

Items maps to align-items.

const (
	ItemsStart    Items = "start"
	ItemsEnd      Items = "end"
	ItemsCenter   Items = "center"
	ItemsBaseline Items = "baseline"
	ItemsStretch  Items = "stretch"
)

func AllItems

func AllItems() []Items

AllItems returns every Items const in stable order.

type Justify

type Justify string

Justify maps to justify-content.

const (
	JustifyStart   Justify = "start"
	JustifyEnd     Justify = "end"
	JustifyCenter  Justify = "center"
	JustifyBetween Justify = "between"
	JustifyAround  Justify = "around"
	JustifyEvenly  Justify = "evenly"
)

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.

const (
	LeadingNone    Leading = "none"
	LeadingTight   Leading = "tight"
	LeadingSnug    Leading = "snug"
	LeadingNormal  Leading = "normal"
	LeadingRelaxed Leading = "relaxed"
	LeadingLoose   Leading = "loose"
)

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 Outline

type Outline string

Outline is a typed outline style.

const (
	OutlineNone   Outline = "none"
	OutlineSolid  Outline = "solid"
	OutlineDashed Outline = "dashed"
	OutlineDotted Outline = "dotted"
	OutlineDouble Outline = "double"
)

func AllOutlines

func AllOutlines() []Outline

AllOutlines returns every Outline in stable order.

type Overflow

type Overflow string

Overflow is a typed overflow style.

const (
	OverflowAuto    Overflow = "auto"
	OverflowHidden  Overflow = "hidden"
	OverflowClip    Overflow = "clip"
	OverflowVisible Overflow = "visible"
	OverflowScroll  Overflow = "scroll"
)

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.

const (
	PositionStatic   Position = "static"
	PositionRelative Position = "relative"
	PositionAbsolute Position = "absolute"
	PositionFixed    Position = "fixed"
	PositionSticky   Position = "sticky"
)

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.

const (
	RadiusNone Radius = "none"
	RadiusSM   Radius = "sm"
	RadiusBase Radius = "base"
	RadiusMD   Radius = "md"
	RadiusLG   Radius = "lg"
	RadiusXL   Radius = "xl"
	Radius2XL  Radius = "2xl"
	Radius3XL  Radius = "3xl"
	RadiusFull Radius = "full"
)

func AllRadii

func AllRadii() []Radius

AllRadii returns every Radius const in stable order.

func (Radius) IsZero

func (r Radius) IsZero() bool

IsZero reports whether the Radius is the zero value.

func (Radius) String

func (r Radius) String() string

String returns the radius key.

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.

const (
	Ring0 RingWidth = "0"
	Ring1 RingWidth = "1"
	Ring2 RingWidth = "2"
	Ring4 RingWidth = "4"
	Ring8 RingWidth = "8"
)

func AllRingWidths

func AllRingWidths() []RingWidth

AllRingWidths returns every RingWidth in stable order.

type Select

type Select string

Select is a typed user-select style.

const (
	SelectNone Select = "none"
	SelectText Select = "text"
	SelectAll  Select = "all"
	SelectAuto Select = "auto"
)

func AllSelects

func AllSelects() []Select

AllSelects returns every Select in stable order.

type Shadow

type Shadow string

Shadow is a typed box-shadow step matching tokens.ShadowScale.

const (
	ShadowNone  Shadow = "none"
	ShadowSM    Shadow = "sm"
	ShadowBase  Shadow = "base"
	ShadowMD    Shadow = "md"
	ShadowLG    Shadow = "lg"
	ShadowXL    Shadow = "xl"
	Shadow2XL   Shadow = "2xl"
	ShadowInner Shadow = "inner"
)

func AllShadows

func AllShadows() []Shadow

AllShadows returns every Shadow const in stable order.

func (Shadow) IsZero

func (s Shadow) IsZero() bool

IsZero reports whether the Shadow is the zero value.

func (Shadow) String

func (s Shadow) String() string

String returns the shadow key.

type Shape

type Shape string

Shape is a typed component shape. Values match the canonical keys in base.Component shape semantics.

const (
	ShapeSquare  Shape = "square"
	ShapeRounded Shape = "rounded"
	ShapeCircle  Shape = "circle"
	ShapePill    Shape = "pill"
)

func AllShapes

func AllShapes() []Shape

AllShapes returns every Shape const in stable order.

func (Shape) IsZero

func (s Shape) IsZero() bool

IsZero reports whether the Shape is the zero value.

func (Shape) String

func (s Shape) String() string

String returns the canonical shape key.

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.

const (
	SizeXS     Size = "xs"
	SizeSmall  Size = "sm"
	SizeMedium Size = "md"
	SizeLarge  Size = "lg"
	SizeXL     Size = "xl"
	Size2XL    Size = "2xl"
)

func AllSizes

func AllSizes() []Size

AllSizes returns every Size const in stable order.

func (Size) IsZero

func (s Size) IsZero() bool

IsZero reports whether the Size is the zero value.

func (Size) String

func (s Size) String() string

String returns the canonical size key.

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.

func (Spacing) IsZero

func (s Spacing) IsZero() bool

IsZero reports whether the Spacing is the zero value.

func (Spacing) String

func (s Spacing) String() string

String returns the spacing key.

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.

func AllStates

func AllStates() []State

AllStates returns every State const in stable order.

func (State) IsZero

func (s State) IsZero() bool

IsZero reports whether the State is the zero value (no prefix).

func (State) Prefix

func (s State) Prefix() string

Prefix returns the Tailwind prefix including the trailing colon (e.g., "hover:"). Returns empty string for the zero value.

func (State) String

func (s State) String() string

String returns the canonical state key.

type TextAlign

type TextAlign string

TextAlign is a typed text alignment.

const (
	TextLeft    TextAlign = "left"
	TextCenter  TextAlign = "center"
	TextRight   TextAlign = "right"
	TextJustify TextAlign = "justify"
)

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.

const (
	TrackingTighter Tracking = "tighter"
	TrackingTight   Tracking = "tight"
	TrackingNormal  Tracking = "normal"
	TrackingWide    Tracking = "wide"
	TrackingWider   Tracking = "wider"
	TrackingWidest  Tracking = "widest"
)

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.

func (Variant) IsZero

func (v Variant) IsZero() bool

IsZero reports whether the Variant is the zero value.

func (Variant) String

func (v Variant) String() string

String returns the canonical variant name.

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 AllZLayers

func AllZLayers() []ZLayer

AllZLayers returns every ZLayer const in stable order.

func (ZLayer) Class

func (z ZLayer) Class() string

Class returns the Tailwind arbitrary-value z-index class. For negative layers, emits "-z-[N]"; for positive, "z-[N]".

func (ZLayer) IsZero

func (z ZLayer) IsZero() bool

IsZero reports whether the ZLayer is the zero value (ZBase). ZBase semantically means "default flow layer", but treat as zero.

func (ZLayer) String

func (z ZLayer) String() string

String returns the numeric value as a decimal string.

Directories

Path Synopsis
Package emission renders CSS for the classes tw compiles, against the PlatformKit design system's custom properties.
Package emission renders CSS for the classes tw compiles, against the PlatformKit design system's custom properties.

Jump to

Keyboard shortcuts

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