|
| 1 | +import { Meta, Typeset } from '@storybook/addon-docs/blocks' |
| 2 | +import { theme } from '../../uno.theme.ts' |
| 3 | + |
| 4 | +<Meta title="Typography" tags={['hide-toolbar']} /> |
| 5 | + |
| 6 | +export const wind4FontSizes = { |
| 7 | + 'xs': '0.75rem', |
| 8 | + 'sm': '0.875rem', |
| 9 | + 'base': '1rem', |
| 10 | + 'lg': '1.125rem', |
| 11 | + 'xl': '1.25rem', |
| 12 | + '2xl': '1.5rem', |
| 13 | + '3xl': '1.875rem', |
| 14 | + '4xl': '2.25rem', |
| 15 | + '5xl': '3rem', |
| 16 | +} |
| 17 | + |
| 18 | +# Typography |
| 19 | + |
| 20 | +The npmx typography system uses Geist for sans-serif text and Geist Mono for monospace code. |
| 21 | + |
| 22 | +Typography values are defined in `uno.theme.ts`. |
| 23 | + |
| 24 | +## Font Families |
| 25 | + |
| 26 | +### Sans Serif — Geist |
| 27 | + |
| 28 | +<Typeset |
| 29 | + fontFamily={theme.font.sans} |
| 30 | + fontSizes={[ |
| 31 | + wind4FontSizes['base'], // 16px |
| 32 | + ]} |
| 33 | + fontWeight={400} |
| 34 | + sampleText="The quick brown fox jumps over the lazy dog" |
| 35 | +/> |
| 36 | + |
| 37 | +<Typeset |
| 38 | + fontFamily={theme.font.sans} |
| 39 | + fontSizes={[ |
| 40 | + wind4FontSizes['5xl'], // 48px |
| 41 | + wind4FontSizes['4xl'], // 36px |
| 42 | + wind4FontSizes['3xl'], // 30px |
| 43 | + wind4FontSizes['2xl'], // 24px |
| 44 | + wind4FontSizes['xl'], // 20px |
| 45 | + wind4FontSizes['lg'], // 18px |
| 46 | + wind4FontSizes['base'], // 16px |
| 47 | + wind4FontSizes['sm'], // 14px |
| 48 | + wind4FontSizes['xs'], // 12px |
| 49 | + theme.text['2xs'].fontSize, // 11px |
| 50 | + theme.text['3xs'].fontSize, // 10px |
| 51 | + theme.text['4xs'].fontSize, // 9px |
| 52 | + theme.text['5xs'].fontSize, // 8px |
| 53 | + ]} |
| 54 | + fontWeight={400} |
| 55 | + sampleText="The quick brown fox jumps over the lazy dog" |
| 56 | +/> |
| 57 | + |
| 58 | +### Monospace — Geist Mono |
| 59 | + |
| 60 | +Code and monospace typography scale: |
| 61 | + |
| 62 | +<Typeset |
| 63 | + fontFamily={theme.font.mono} |
| 64 | + fontSizes={[ |
| 65 | + wind4FontSizes['base'], // 16px |
| 66 | + ]} |
| 67 | + fontWeight={400} |
| 68 | + sampleText="const greeting = 'Hello, World!';" |
| 69 | +/> |
| 70 | + |
| 71 | +<Typeset |
| 72 | + fontFamily={theme.font.mono} |
| 73 | + fontSizes={[ |
| 74 | + wind4FontSizes['5xl'], // 48px |
| 75 | + wind4FontSizes['4xl'], // 36px |
| 76 | + wind4FontSizes['3xl'], // 30px |
| 77 | + wind4FontSizes['2xl'], // 24px |
| 78 | + wind4FontSizes['xl'], // 20px |
| 79 | + wind4FontSizes['lg'], // 18px |
| 80 | + wind4FontSizes['base'], // 16px |
| 81 | + wind4FontSizes['sm'], // 14px |
| 82 | + wind4FontSizes['xs'], // 12px |
| 83 | + theme.text['2xs'].fontSize, // 11px |
| 84 | + theme.text['3xs'].fontSize, // 10px |
| 85 | + theme.text['4xs'].fontSize, // 9px |
| 86 | + theme.text['5xs'].fontSize, // 8px |
| 87 | + ]} |
| 88 | + fontWeight={400} |
| 89 | + sampleText="const greeting = 'Hello, World!';" |
| 90 | +/> |
| 91 | + |
| 92 | +## Font Sizes |
| 93 | + |
| 94 | +The complete typography scale combines custom micro sizes (`5xs`-`2xs` from our theme) with standard Wind4 preset sizes (`xs`-`5xl`). |
| 95 | + |
| 96 | +**Custom Micro Sizes (from `theme.text`):** |
| 97 | + |
| 98 | +- `5xs` = {theme.text['5xs'].fontSize} (8px) |
| 99 | +- `4xs` = {theme.text['4xs'].fontSize} (9px) |
| 100 | +- `3xs` = {theme.text['3xs'].fontSize} (10px) |
| 101 | +- `2xs` = {theme.text['2xs'].fontSize} (11px) |
| 102 | + |
| 103 | +**Wind4 Standard Sizes:** |
| 104 | + |
| 105 | +- `xs` = {wind4FontSizes['xs']} (12px) |
| 106 | +- `sm` = {wind4FontSizes['sm']} (14px) |
| 107 | +- `base` = {wind4FontSizes['base']} (16px) |
| 108 | +- `lg` = {wind4FontSizes['lg']} (18px) |
| 109 | +- `xl` = {wind4FontSizes['xl']} (20px) |
| 110 | +- `2xl` = {wind4FontSizes['2xl']} (24px) |
| 111 | +- `3xl` = {wind4FontSizes['3xl']} (30px) |
| 112 | +- `4xl` = {wind4FontSizes['4xl']} (36px) |
| 113 | +- `5xl` = {wind4FontSizes['5xl']} (48px) |
| 114 | + |
| 115 | +## Font Weights |
| 116 | + |
| 117 | +<Typeset |
| 118 | + fontFamily={theme.font.sans} |
| 119 | + fontSizes={['1rem']} |
| 120 | + fontWeight={300} |
| 121 | + sampleText="Light (300) — Used sparingly for decorative purposes" |
| 122 | +/> |
| 123 | + |
| 124 | +<Typeset |
| 125 | + fontFamily={theme.font.sans} |
| 126 | + fontSizes={['1rem']} |
| 127 | + fontWeight={400} |
| 128 | + sampleText="Regular (400) — Default weight for body text and most content" |
| 129 | +/> |
| 130 | + |
| 131 | +<Typeset |
| 132 | + fontFamily={theme.font.sans} |
| 133 | + fontSizes={['1rem']} |
| 134 | + fontWeight={500} |
| 135 | + sampleText="Medium (500) — Used for emphasis and section headings" |
| 136 | +/> |
| 137 | + |
| 138 | +<Typeset |
| 139 | + fontFamily={theme.font.sans} |
| 140 | + fontSizes={['1rem']} |
| 141 | + fontWeight={600} |
| 142 | + sampleText="Semibold (600) — Used for strong emphasis and primary actions" |
| 143 | +/> |
| 144 | + |
| 145 | +<Typeset |
| 146 | + fontFamily={theme.font.sans} |
| 147 | + fontSizes={['1rem']} |
| 148 | + fontWeight={700} |
| 149 | + sampleText="Bold (700) — Used for headings and important labels" |
| 150 | +/> |
| 151 | + |
| 152 | +## Line Height |
| 153 | + |
| 154 | +Base line height is set to **1.6** for optimal readability. This provides comfortable spacing for multi-line text blocks while maintaining density for UI components. |
| 155 | + |
| 156 | +## Typography Features |
| 157 | + |
| 158 | +- **Font smoothing**: Antialiased rendering (`-webkit-font-smoothing: antialiased`) applied globally |
| 159 | +- **Text rendering**: `optimizeLegibility` applied globally for consistent cross-browser rendering |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +## Related |
| 164 | + |
| 165 | +- [Design System Guidelines](https://storybook.npmx.dev/?path=/docs/guidelines--docs) - See typography guidelines and usage |
| 166 | +- [Colors](https://storybook.npmx.dev/?path=/docs/colors--docs) - View the color system |
0 commit comments