Typography API

API reference for the Typography component: its props with their token values and defaults, the styled-system prop groups, and forwarded HTML attributes.

Demos

For usage examples, visit the component demo page: Typography

Import

import { Typography } from '@soroush.tech/design-system/Typography'

Typography-specific props

variant

Maps the component to a semantic HTML element and applies a typographic scale from the theme.

VariantElementfontSizefontWeight
h1<h1>6 (48px)bold
h2<h2>5 (32px)bold
h3<h3>4 (24px)bold
h4<h4>3 (20px)bold
h5<h5>2 (16px)bold
h6<h6>1 (14px)semiBold
subtitle1<h6>2 (16px)medium
subtitle2<h6>1 (14px)medium
body1<p>2 (16px)normal
body2<p>1 (14px)normal
caption<span>0 (12px)normal
overline<span>0 (12px)medium + uppercase + letterSpacing="wider"
button<span>1 (14px)medium + uppercase + letterSpacing="wide"
inherit<p>inheritinherit

Default: body1. Individual props (fontSize, fontWeight, etc.) override variant styles when both are provided.

color

Resolves against theme.text. All 9 semantic tokens are available:

TokenDark sourceLight source
"inherit"CSS keywordCSS keyword
"initial"kineticSurface[100]kineticSurface[900]
"primary"kineticGreen[500]kineticSurface[900]
"secondary"kineticSurface[400]kineticGreen[800]
"disabled"kineticSurface[500]kineticSurface[900] + 30% opacity
"error"neonRed[700]neonRed[700]
"success"kineticGreen[700]kineticGreen[700]
"info"cyberCyan[500]cyberCyan[800]
"warning"solarAmber[800]solarAmber[800]

align

ValueCSS
"left"text-align: left
"center"text-align: center
"right"text-align: right
"justify"text-align: justify - stretches wrapped lines only; last line stays left
"inherit"text-align: inherit

gutterBottom

boolean - adds margin-bottom: 0.5em. Useful between a heading and the following paragraph without needing a space prop.


noWrap

boolean - applies overflow: hidden, text-overflow: ellipsis, white-space: nowrap. The element must have a constrained width for truncation to trigger.


as

Overrides the HTML element chosen by variant while keeping its visual styles.

<Typography variant="h1" as="div" />       // div with h1 styles
<Typography variant="body1" as="span" />   // inline with body1 styles
<Typography variant="inherit" as="code" /> // code element, inherits styles

Styled-system props

Space - theme.space

PropShorthand for
m mt mr mb ml mx mymargin + sides
p pt pr pb pl px pypadding + sides
KeyValue
00
0.54px
18px
1.512px
216px
324px
432px
540px
648px
756px
864px
"auto"auto

Layout

width · height · minWidth · minHeight · maxWidth · maxHeight · display · overflow · overflowX · overflowY · verticalAlign


bg - theme.background

TokenDark sourceLight source
"backdrop"carbonBlack[900] + 80% opacitykineticSurface[100] + 80% opacity
"modal"kineticSurface[800]kineticSurface[100]
"primary"kineticSurface[900]kineticSurface[50]
"secondary"kineticSurface[700]carbonBlack[100]
"paper"kineticSurface[800]kineticSurface[100]

Typography - theme scales

PropCSS propertyScale
fontFamilyfont-familytheme.fonts keyword
fontSizefont-sizetheme.fontSizes index
fontWeightfont-weighttheme.fontWeights keyword
lineHeightline-heighttheme.lineHeights keyword
letterSpacingletter-spacingtheme.letterSpacings keyword
textAligntext-alignraw CSS (prefer align prop)
fontStylefont-styleraw CSS

Constraint: textTransform has no styled-system function - it must live in a styled(Typography) CSS template literal or inside a variant() definition.

Font family - theme.fonts

KeyValue
"body"'Space Grotesk', sans-serif
"heading"'Space Grotesk', sans-serif
"mono"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace

Font size - theme.fontSizes (pass index)

Indexpx
012
114
216
320
424
532
648

Font weight - theme.fontWeights (pass keyword)

KeywordWeight
"thin"100
"extraLight"200
"light"300
"normal"400
"medium"500
"semiBold"600
"bold"700
"extraBold"800
"black"900

Line height - theme.lineHeights (pass keyword)

KeywordValueUse
"none"1tight display text
"tight"1.2headings
"snug"1.35sub-headings
"base"1.5body text
"relaxed"1.625readable long-form
"loose"2wide airy layouts

Letter spacing - theme.letterSpacings (pass keyword)

KeywordValue
"tighter"-0.05em
"tight"-0.025em
"normal"0em
"wide"0.05em
"wider"0.1em
"widest"0.2em

Flexbox

alignItems · alignContent · justifyContent · justifyItems · flexDirection · flexWrap · flex · flexGrow · flexShrink · flexBasis · alignSelf · justifySelf · order


Border - theme.radii

border · borderWidth · borderStyle · borderColor · borderRadius · borderTop · borderRight · borderBottom · borderLeft · borderX · borderY

Radii: "sm" (4px) · "md" (8px) · "lg" (16px)


Position

position · zIndex · top · right · bottom · left


HTML attributes

Typography extends HTMLAttributes<HTMLElement> (minus color, which is overridden). All standard attributes pass through: style, className, onClick, data-*, aria-*, etc.


Source code

If this page does not answer your question, have a look at the implementation of the component for more detail.