All utilities accept values and return a StyleRule. Use them with tw (chainable) or cx() (functional). Most accept Tailwind-style string lookups directly.
Numbers map to the spacing scale (4 = 1rem, each unit = 0.25rem). Strings pass through as raw CSS.
Utility CSS Property p(value)paddingpx(value)padding-left, padding-rightpy(value)padding-top, padding-bottompt(value), pr(value), pb(value), pl(value)Individual sides
tw . px ( 6 ) // padding-left: 1.5rem; padding-right: 1.5rem
tw . py ( ' 10px ' ) // padding-top: 10px; padding-bottom: 10px
Utility CSS Property m(value)marginmx(value)margin-left, margin-rightmy(value)margin-top, margin-bottommt(value), mr(value), mb(value), ml(value)Individual sides
tw . mx ( ' auto ' ) // margin-left: auto; margin-right: auto
Utility CSS Property gap(value)gapgapX(value)column-gapgapY(value)row-gap
tw . gapX ( 2 ) // column-gap: 0.5rem
Accept property-access tokens, Tailwind-style string lookups, or raw CSS color strings.
Utility CSS Property bg(color)background-colortextColor(color)colorborderColor(color)border-color
// Property-access tokens (recommended)
tw . bg . blue500 // background-color: #3b82f6
tw . textColor . gray900 // color: #111827
tw . borderColor . gray200 // border-color: #e5e7eb
tw . bg . blue500 ( 50 ) // with opacity: rgb(59 130 246 / 0.5)
// String lookups (equivalent)
Utility CSS Property Notes text(size)font-size + line-heightAccepts tokens: tw.text.lg, tw.text._2xl font(weight)font-weightAccepts tokens: tw.font.bold, tw.font.semibold fontFamily(value)font-familyAccepts tokens: tw.fontFamily.sans, tw.fontFamily.mono tracking(value)letter-spacingAccepts tokens: tw.tracking.tight, tw.tracking.wide leading(value)line-heightAccepts tokens: tw.leading.tight, tw.leading.relaxed textAlign(value)text-alignAccepts tokens: tw.textAlign.center, tw.textAlign.right
// Property-access tokens (recommended)
tw . text . lg // font-size: 1.125rem; line-height: 1.75rem
tw . text . _2xl // font-size: 1.5rem; line-height: 2rem
tw . font . bold // font-weight: 700
tw . font . semibold // font-weight: 600
tw . textAlign . center // text-align: center
// String lookups (equivalent)
fontFamily() ships with Tailwind’s default font stacks built in:
tw . fontFamily ( ' sans ' ) // ui-sans-serif, system-ui, sans-serif, ...
tw . fontFamily ( ' serif ' ) // ui-serif, Georgia, Cambria, "Times New Roman", ...
tw . fontFamily ( ' mono ' ) // ui-monospace, SFMono-Regular, Menlo, Monaco, ...
You can also pass any CSS font family string directly:
tw . fontFamily ( ' Georgia, serif ' )
The built-in googleFonts plugin loads a Google Font and returns the family name for use with fontFamily(). It automatically injects the <link> tag in the browser.
import { tw, googleFonts } from ' typewritingclass '
tw . fontFamily ( googleFonts ( ' Inter ' ))
tw . fontFamily ( googleFonts ( ' Roboto ' , { weights: [ 400 , 500 , 700 ] }))
tw . fontFamily ( googleFonts ( ' Fira Code ' , { display: ' block ' }))
Each font is only loaded once, even if googleFonts() is called multiple times with the same family name.
Utility CSS flex()display: flexflexCol()display: flex; flex-direction: columnflexRow()display: flex; flex-direction: rowflexWrap()flex-wrap: wrapinlineFlex()display: inline-flex
tw . flex . items . center . justify . between
Utility CSS grid(cols?)display: grid (optionally with columns)gridCols(n)grid-template-columns: repeat(n, ...)gridRows(n)grid-template-rows: repeat(n, ...)
tw . grid ( 3 ) . gap ( 4 ) // 3-column grid with 1rem gap
Utility CSS Property w(value)widthh(value)heightsize(value)width + heightminW(value), minH(value)min-width, min-heightmaxW(value), maxH(value)max-width, max-height
tw . size ( 10 ) // width: 2.5rem; height: 2.5rem
Utility CSS Property items(value)align-itemsjustify(value)justify-contentself(value)align-self
Utility CSS Property overflow(value)overflowoverflowX(value)overflow-xoverflowY(value)overflow-y
Utility CSS relative()position: relativeabsolute()position: absolutefixed()position: fixedsticky()position: stickytop(value), right(value), bottom(value), left(value)Offsets inset(value)inset shorthandz(value)z-indexdisplay(value)display
tw . fixed . top ( 0 ) . left ( 0 ) . w ( ' full ' )
Utility CSS Property rounded(value?)border-radius (default: 0.25rem)roundedT(value?), roundedB(value?), roundedL(value?), roundedR(value?)Corner-specific border(width?)border-width + border-style: solid (default: 1px)borderT(width?), borderR(width?), borderB(width?), borderL(width?)Side-specific ring(width?, color?)box-shadow as focus ring (default: 3px, #3b82f6)
tw . rounded . lg // border-radius: 0.5rem
tw . rounded . full // border-radius: 9999px
tw . border () . borderColor . gray200
tw . focusVisible (tw . ring ( ' 2px ' , ' #3b82f6 ' ))
Utility CSS Property shadow(value?)box-shadowopacity(value)opacity (0-1)backdrop(value)backdrop-filter
tw . shadow . md // medium shadow
tw . shadow . lg . hover (tw . shadow . xl )
Shadow accepts string lookups: 'sm', 'md', 'lg', 'xl', '2xl', 'inner', 'none'.
Utility CSS Property cursor(value)cursorselect(value)user-selectpointerEvents(value)pointer-events
All utilities that accept DynamicValue work with dcx():
import { dcx, bg, rounded, p, dynamic } from ' typewritingclass '
const { className , style } = dcx (
rounded ( dynamic (radius)) ,
< div className = {className} style = {style} />
. hover (tw . shadow . lg . bg . gray50 )
< div className = {card} > Card content </ div >