Documentation
¶
Overview ¶
Package u is the Tailwind-shaped typed utility engine layered over the css Layer-1 foundation. Every utility is a typed Go symbol (no class-string parser), so the whole surface is autocompletable and compile-checked. Each utility resolves its argument against the active css.Theme and returns Layer-1 css.Rule(s); emission, dedup, and SSR reuse the Layer-1 registry/sink unchanged.
This is the curated core (spacing/color/type/flex/border/effects + the responsive/state variants). The design's full-parity surface is generated from a spec table over the theme; the core lands first and the long tail is incremental table entries.
Index ¶
- Constants
- Variables
- func Active(rules ...css.Rule) []css.Rule
- func Bg(c css.Color) css.Rule
- func BgC(c ColorToken) css.Rule
- func BgToken(name string) css.Ruledeprecated
- func Border(c css.Color) css.Rule
- func BorderC(c ColorToken) css.Rule
- func Dark(rules ...css.Rule) []css.Rule
- func Fg(c css.Color) css.Rule
- func Focus(rules ...css.Rule) []css.Rule
- func Gap(index Spacing) css.Rule
- func GapV(v css.Length) css.Rule
- func GroupHover(rules ...css.Rule) []css.Rule
- func H(index Spacing) css.Rule
- func Hover(rules ...css.Rule) []css.Rule
- func Important(rules ...css.Rule) []css.Rule
- func Lg(rules ...css.Rule) []css.Rule
- func M(index Spacing) css.Rule
- func Md(rules ...css.Rule) []css.Rule
- func MtN(index Spacing) css.Rule
- func Mx(index Spacing) css.Rule
- func My(index Spacing) css.Rule
- func Opacity(pct int) css.Rule
- func Pad(index Spacing) css.Rule
- func PadX(index Spacing) css.Rule
- func PadY(index Spacing) css.Rule
- func PeerFocus(rules ...css.Rule) []css.Rule
- func Rounded(r Radius) css.Rule
- func Sm(rules ...css.Rule) []css.Rule
- func TextC(c ColorToken) css.Rule
- func TextSize(scale TextScale) css.Rule
- func TextToken(name string) css.Ruledeprecated
- func W(index Spacing) css.Rule
- func WhenDisabled(rules ...css.Rule) []css.Rule
- func Xl(rules ...css.Rule) []css.Rule
- func Xl2(rules ...css.Rule) []css.Rule
- type Angle
- type Color
- type ColorToken
- type Duration
- type Easing
- type Frame
- type Length
- type MediaQ
- type NthArg
- type Number
- type Radius
- type Rule
- type Selector
- type Sheet
- type Sink
- type Spacing
- type TextScale
- type Theme
- type TransProp
Constants ¶
const ( ShadowNone = css.ShadowNone ShadowSm = css.ShadowSm ShadowMd = css.ShadowMd ShadowLg = css.ShadowLg ShadowXl = css.ShadowXl Shadow2xl = css.Shadow2xl PropAll = css.PropAll PropColors = css.PropColors PropOpacity = css.PropOpacity PropTransform = css.PropTransform PropShadow = css.PropShadow Linear = css.Linear Ease = css.Ease EaseIn = css.EaseIn EaseOut = css.EaseOut EaseInOut = css.EaseInOut )
const ( White = css.White Black = css.Black Slate100 = css.Slate100 Slate500 = css.Slate500 Slate800 = css.Slate800 Slate900 = css.Slate900 Sky500 = css.Sky500 Red500 = css.Red500 )
Color tokens re-exported for ergonomic u.Slate900 style call sites.
Variables ¶
var ( Class = css.Class New = css.New Rules = css.Rules DefineUtility = css.DefineUtility Utility = css.Utility DefineVariant = css.DefineVariant UseTheme = css.UseTheme DefaultTheme = css.DefaultTheme Reset = css.Reset Harvest = css.Harvest // available on both build lanes Seed = css.Seed SetSink = css.SetSink MarkImportant = css.MarkImportant )
var ( Px = css.Px // length: Px(8) -> "8px" Rem = css.Rem Ems = css.Ems Percent = css.Percent Vh = css.Vh Vw = css.Vw RawLength = css.RawLength Num = css.Num Ms = css.Ms S = css.S Deg = css.Deg Turn = css.Turn Hex = css.Hex RGB = css.RGB RGBA = css.RGBA CSSVar = css.Var FontSize = css.FontSize MinWidth = css.MinWidth MaxWidth = css.MaxWidth MinHeight = css.MinHeight MaxHeight = css.MaxHeight )
var ( Raw = css.Raw Sel = css.Sel )
Raw and Sel are the documented escape hatches for the typed utility surface. The curated utilities cover the common surface, not every CSS property; when none fits, drop to a raw declaration rather than reaching outside the engine. Raw(property, value) emits one declaration and Sel(selector, rules...) emits an arbitrary selector — both fold, dedup, content-hash, and emit through the SAME Layer-1 registry/sink as every typed utility, so a raw style still gets a stable class name and SSR reuse (it is not an unmanaged inline style). Reach for these only for the long tail; prefer a typed utility whenever one exists so the style stays autocompletable and compile-checked.
// no typed aspect-ratio utility → use the raw escape hatch, still registry-managed:
css.New(u.Pad(u.Spacing4), u.Raw("aspect-ratio", "16 / 9"))
var ( Media = css.Media MinW = css.MinW MaxW = css.MaxW RawMedia = css.RawMedia FocusVisible = css.FocusVisible Before = css.Before After = css.After Keyframes = css.Keyframes At = css.At Animation = css.Animation Child = css.Child Descendant = css.Descendant Adjacent = css.Adjacent Sibling = css.Sibling Not = css.Not Has = css.Has Is = css.Is NthChild = css.NthChild NthOfType = css.NthOfType AnB = css.AnB Nth = css.Nth )
var ( El = css.El SheetRef = css.SheetRef ClassSel = css.ClassSel AttrSel = css.AttrSel AttrEq = css.AttrEq )
var ( Cursor = css.Cursor UserSelect = css.UserSelect TextTransform = css.TextTransform FontVariantNumeric = css.FontVariantNumeric )
var ( Shadow = css.Shadow Transition = css.Transition Prop = css.Prop Transform = css.Transform Scale = css.Scale ScaleXY = css.ScaleXY Rotate = css.Rotate TranslateX = css.TranslateX TranslateY = css.TranslateY Outline = css.Outline OutlineOffset = css.OutlineOffset Tracking = css.Tracking LineHeight = css.LineHeight LineHeightLen = css.LineHeightLen CubicBezier = css.CubicBezier )
var ( Block = css.Display.Block InlineBlock = css.Display.InlineBlock Inline = css.Display.Inline Flex = css.Display.Flex InlineFlex = css.Display.InlineFlex Grid = css.Display.Grid Hide = css.Display.None FlexRow = css.FlexDir.Row FlexCol = css.FlexDir.Col ItemsStart = css.Items.Start ItemsCenter = css.Items.Center ItemsEnd = css.Items.End ItemsStretch = css.Items.Stretch JustifyStart = css.Justify.Start JustifyCenter = css.Justify.Center JustifyEnd = css.Justify.End JustifyBetween = css.Justify.Between JustifyAround = css.Justify.Around Relative = css.Position.Relative Absolute = css.Position.Absolute Fixed = css.Position.Fixed Sticky = css.Position.Sticky FontNormal = css.FontWeight.Normal FontMedium = css.FontWeight.Medium FontSemibold = css.FontWeight.Semibold FontBold = css.FontWeight.Bold )
Functions ¶
func BgC ¶
func BgC(c ColorToken) css.Rule
BgC / TextC / BorderC set background / text / border color from a typed theme color token: u.BgC(u.ColorSlate900). A typo is a compile error (the constant does not exist) and the token set autocompletes — the canonical, type-safe path. For a custom theme, `gwc css gen` generates the matching u.ColorToken constants.
func BgToken
deprecated
BgToken / TextToken resolve a theme color token name ("slate-900"); an unknown token resolves to transparent so a typo fails visibly rather than silently inheriting.
Deprecated: prefer the typed u.BgC(u.ColorSlate900) / u.TextC(...), where a typo is a compile error instead of a runtime transparent fallback. These string forms remain for arbitrary/runtime-computed token names.
func BorderC ¶
func BorderC(c ColorToken) css.Rule
func GroupHover ¶
Group/Peer variants via parent/sibling state selectors. Mark the parent with the "group"/"peer" class (plain html.Class("group")).
func Important ¶
Important appends !important to every declaration in the given rules. Use sparingly — it is the typed analog of Tailwind's "!" modifier.
func TextC ¶
func TextC(c ColorToken) css.Rule
Types ¶
type Color ¶
const ( Transparent Color = css.Transparent CurrentColor Color = css.CurrentCo Slate50 Color = css.Slate50 Slate200 Color = css.Slate200 Slate300 Color = css.Slate300 Slate400 Color = css.Slate400 Slate600 Color = css.Slate600 Slate700 Color = css.Slate700 Sky400 Color = css.Sky400 Sky600 Color = css.Sky600 Red600 Color = css.Red600 Green500 Color = css.Green500 Amber500 Color = css.Amber500 )
type ColorToken ¶
type ColorToken string
ColorToken is a typed theme color-token key, so a color reference autocompletes and a typo is a compile error instead of a silent transparent fallback. The constants below cover css.DefaultTheme; a custom theme's tokens are generated into the application package by `gwc css gen` (same shape, also u.ColorToken).
const ( ColorTransparent ColorToken = "transparent" ColorCurrent ColorToken = "current" ColorWhite ColorToken = "white" ColorBlack ColorToken = "black" ColorSlate50 ColorToken = "slate-50" ColorSlate100 ColorToken = "slate-100" ColorSlate200 ColorToken = "slate-200" ColorSlate300 ColorToken = "slate-300" ColorSlate400 ColorToken = "slate-400" ColorSlate500 ColorToken = "slate-500" ColorSlate600 ColorToken = "slate-600" ColorSlate700 ColorToken = "slate-700" ColorSlate800 ColorToken = "slate-800" ColorSlate900 ColorToken = "slate-900" ColorSky400 ColorToken = "sky-400" ColorSky500 ColorToken = "sky-500" ColorSky600 ColorToken = "sky-600" ColorRed500 ColorToken = "red-500" ColorRed600 ColorToken = "red-600" ColorGreen500 ColorToken = "green-500" ColorAmber500 ColorToken = "amber-500" )
type MediaQ ¶
type MediaQ = css.MediaQuery
type Spacing ¶
type Spacing int
Spacing is a typed spacing-scale index. Built-in steps are provided as constants; any int is still valid (Tailwind's n*0.25rem formula), so arbitrary indices need no escape hatch.
type TransProp ¶
type TransProp = css.TransitionProperty