Utility Functions
Every CSS property is a TypeScript function. Call it with a value, get a StyleRule. Compose with tw or cx().
Spacing
Section titled “Spacing”Numeric values use the Tailwind-compatible spacing scale (4 = 1rem, each unit = 0.25rem). Strings pass through as raw CSS.
tw.p(4) // padding: 1remtw.px(6) // padding-left/right: 1.5remtw.m('auto') // margin: autotw.gap(4) // gap: 1remAll spacing utilities: p, px, py, pt, pr, pb, pl, m, mx, my, mt, mr, mb, ml, gap, gapX, gapY
Colors
Section titled “Colors”Use property-access tokens for design tokens, or pass raw CSS strings:
// Property-access tokenstw.bg.blue500 // background-color: #3b82f6tw.textColor.slate900 // color: #0f172atw.borderColor.gray200 // border-color: #e2e8f0
// With opacitytw.bg.blue500(50) // background-color: rgb(59 130 246 / 0.5)
// Raw CSS valuestw.bg('#ff6347')Typography
Section titled “Typography”// Property-access tokenstw.text.lg // font-size + line-height presettw.text.xl // font-size: 1.25rem; line-height: 1.75remtw.font.bold // font-weight: 700tw.font.semibold // font-weight: 600
// Function calls for arbitrary valuestw.text('2xl') // font-size: 1.5rem; line-height: 2remtw.font('700') // font-weight: 700tw.tracking('-0.025em') // letter-spacingtw.leading('1.5') // line-heighttw.textAlign.center // text-align: centerLayout
Section titled “Layout”tw.flex.flexCol.items.center.justify.betweentw.grid(3).gap(4) // 3-column grid with 1rem gaptw.w('100%').h('100vh')tw.relative.absolute.fixed.stickytw.z(10).inset(0)tw.display.none.overflow.hiddenBorders
Section titled “Borders”// Property-access tokenstw.rounded.lg // border-radius: 0.5remtw.rounded.full // border-radius: 9999px
// Function callstw.border(1) // border-width: 1pxtw.ring(2) // focus ringEffects
Section titled “Effects”// Property-access tokenstw.shadow.md // box-shadowtw.shadow.lg
// Function callstw.opacity(0.5)tw.backdrop('blur(8px)')Interactivity
Section titled “Interactivity”// Property-access tokenstw.cursor.pointertw.cursor.notAllowed
// Function callstw.select('none')tw.pointerEvents('none')Theme tokens vs raw values
Section titled “Theme tokens vs raw values”Most utilities accept both property-access tokens and raw CSS strings:
// Property-access tokens (recommended for design tokens)tw.bg.blue500.rounded.lg.shadow.md
// String lookups (equivalent)tw.bg('blue-500').rounded('lg').shadow('md')
// Raw CSS (for one-off values)tw.bg('#ff6347').rounded('0.625rem').shadow('0 4px 12px rgba(0,0,0,0.15)')Standalone utilities
Section titled “Standalone utilities”Utilities imported individually also support property-access tokens:
import { cx, bg, rounded, shadow, p } from 'typewritingclass'
cx(bg.blue500, rounded.lg, shadow.md, p(4))
// With opacitycx(bg.blue500(25), rounded.lg, p(4))