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”Accept Tailwind-style string lookups or raw CSS colors:
tw.bg('blue-500') // background-color: #3b82f6tw.textColor('slate-900') // color: #0f172atw.borderColor('gray-200') // border-color: #e2e8f0tw.bg('#ff6347') // raw hexTypography
Section titled “Typography”import { lg } from 'typewritingclass/theme/typography'
tw.text(lg) // font-size + line-height presettw.font('700') // font-weight: 700tw.tracking('-0.025em') // letter-spacingtw.leading('1.5') // line-heighttw.textAlign('center') // text-alignLayout
Section titled “Layout”tw.flex.flexCol.items('center').justify('space-between')tw.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('hidden')Borders
Section titled “Borders”tw.rounded('lg') // border-radius: 0.5remtw.rounded('full') // border-radius: 9999pxtw.border(1) // border-width: 1pxtw.ring(2) // focus ringEffects
Section titled “Effects”tw.shadow('md') // box-shadowtw.shadow('lg')tw.opacity(0.5)tw.backdrop('blur(8px)')Interactivity
Section titled “Interactivity”tw.cursor('pointer')tw.select('none')tw.pointerEvents('none')Theme tokens vs raw values
Section titled “Theme tokens vs raw values”Most utilities accept both Tailwind-style string lookups and raw CSS:
// String lookupstw.bg('blue-500').rounded('lg').shadow('md')
// Raw CSStw.bg('#ff6347').rounded('0.625rem').shadow('0 4px 12px rgba(0,0,0,0.15)')