Typography Utilities
NuvoUI provides a comprehensive set of typography utilities to control text appearance including font size, weight, alignment, decoration, and text overflow handling.
Configuration
Typography utilities are built on configurable variables.
Font Sizes
The system uses a set of predefined font sizes, which can be updated in the Typography Configuration section.
Breakpoints
Responsive typography variants are based on these breakpoint values:
Font Size
Control the font size of text using the .text-{size}
utilities:
Font Weight
Control the font weight of text using the .font-{weight}
utilities:
Line Height
Control the line height of text using the .leading-{size}
utilities:
Text Alignment
Control text alignment using the .text-{alignment}
utilities:
Text Transform
Control the text casing using the text transform utilities:
Font Style
Control the font style using the font style utilities:
Text Decoration
Add or remove text decorations using these utilities:
Text Overflow
Control how text overflows its container:
The truncate
utility will truncate the text with an ellipsis (...
). Do not use padding for multine e.g. truncate-2
or truncate-3
Text Break
Control how text breaks and wraps:
Whitespace
Control how whitespace is handled:
Letter Spacing
Control the tracking (letter spacing) of text:
Responsive Typography
All typography utilities can be applied conditionally at different breakpoints using the @{breakpoint}
suffix:
Typography Utilities Reference Table
Font Size Classes
Class | CSS Property | Description |
---|---|---|
.text-xs | font-size: 0.75rem | Extra small text |
.text-sm | font-size: 0.875rem | Small text |
.text-md | font-size: 1rem | Base text size (16px) |
.text-base | font-size: 1rem | Base text size (16px) |
.text-lg | font-size: 1.125rem | Large text |
.text-xl | font-size: 1.5rem | Extra large text |
.text-2xl | font-size: 1.75rem | 2x large text |
.text-3xl | font-size: 2rem | 3x large text |
.text-4xl | font-size: 2.5rem | 4x large text |
Font Weight Classes
Class | CSS Property | Description |
---|---|---|
.font-thin | font-weight: 100 | Thin font weight |
.font-extralight | font-weight: 200 | Extra light font weight |
.font-light | font-weight: 300 | Light font weight |
.font-normal | font-weight: 400 | Normal/regular font weight |
.font-medium | font-weight: 500 | Medium font weight |
.font-semibold | font-weight: 600 | Semi-bold font weight |
.font-bold | font-weight: 700 | Bold font weight |
.font-extrabold | font-weight: 800 | Extra bold font weight |
.font-black | font-weight: 900 | Black (heaviest) font weight |
Line Height Classes
Class | CSS Property | Description |
---|---|---|
.leading-none | line-height: 1 | No line height (tight) |
.leading-tight | line-height: 1.25 | Tight line height |
.leading-snug | line-height: 1.375 | Snug line height |
.leading-normal | line-height: 1.5 | Normal line height |
.leading-relaxed | line-height: 1.625 | Relaxed line height |
.leading-loose | line-height: 2 | Loose line height |
Text Alignment Classes
Class | CSS Property | Description |
---|---|---|
.text-left | text-align: left | Left-aligned text |
.text-center | text-align: center | Center-aligned text |
.text-right | text-align: right | Right-aligned text |
.text-justify | text-align: justify | Justified text |
Text Transform Classes
Class | CSS Property | Description |
---|---|---|
.uppercase | text-transform: uppercase | All uppercase text |
.lowercase | text-transform: lowercase | All lowercase text |
.capitalize | text-transform: capitalize | Capitalized text |
.normal-case | text-transform: none | Normal case text (no transform) |
Font Style Classes
Class | CSS Property | Description |
---|---|---|
.italic | font-style: italic | Italic text |
.not-italic | font-style: normal | Normal text (not italic) |
Text Decoration Classes
Class | CSS Property | Description |
---|---|---|
.underline | text-decoration: underline | Underlined text |
.line-through | text-decoration: line-through | Strikethrough text |
.no-underline | text-decoration: none | No text decoration |
Text Overflow Classes
Class | CSS Property | Description |
---|---|---|
.truncate | Multiple properties | Truncates text with ellipsis in one line |
.overflow-label | Multiple properties | Handles overflow for labels with min-width support |
.truncate-2 | Multiple properties | Truncates text after 2 lines |
.truncate-3 | Multiple properties | Truncates text after 3 lines |
.truncate-4 | Multiple properties | Truncates text after 4 lines |
.truncate-5 | Multiple properties | Truncates text after 5 lines |
Word Break Classes
Class | CSS Property | Description |
---|---|---|
.break-normal | Multiple properties | Normal word breaks |
.break-words | overflow-wrap: break-word | Breaks words to prevent overflow |
.break-all | word-break: break-all | Breaks words at any character |
Whitespace Classes
Class | CSS Property | Description |
---|---|---|
.whitespace-normal | white-space: normal | Normal whitespace handling |
.whitespace-nowrap | white-space: nowrap | Prevents text from wrapping |
.whitespace-pre | white-space: pre | Preserves whitespace exactly |
.whitespace-pre-line | white-space: pre-line | Preserves line breaks, collapses spaces |
.whitespace-pre-wrap | white-space: pre-wrap | Preserves whitespace but wraps text |
Letter Spacing Classes
Class | CSS Property | Description |
---|---|---|
.tracking-tighter | letter-spacing: -0.05em | Tighter letter spacing |
.tracking-tight | letter-spacing: -0.025em | Tight letter spacing |
.tracking-normal | letter-spacing: 0 | Normal letter spacing |
.tracking-wide | letter-spacing: 0.025em | Wide letter spacing |
.tracking-wider | letter-spacing: 0.05em | Wider letter spacing |
.tracking-widest | letter-spacing: 0.1em | Widest letter spacing |
Responsive Classes
Add @{breakpoint}
suffix to any typography class to apply it at a specific breakpoint:
.text-xl@md
.font-bold@lg
.text-center@xl
.truncate-3@sm
.tracking-wide@md
SCSS Mixins
NuvoUI provides a comprehensive set of typography mixins for use in your SCSS:
Font Size Mixin
Mixin | Parameters | Description |
---|---|---|
@include text-size($size) | $size : Size name or value | Sets font size from the size map or direct value |
Font Weight Mixins
Mixin | Description | Parameters |
---|---|---|
@include font-thin | Sets font-weight to 100 | None |
@include font-extralight | Sets font-weight to 200 | None |
@include font-light | Sets font-weight to 300 | None |
@include font-normal | Sets font-weight to 400 | None |
@include font-medium | Sets font-weight to 500 | None |
@include font-semibold | Sets font-weight to 600 | None |
@include font-bold | Sets font-weight to 700 | None |
@include font-extrabold | Sets font-weight to 800 | None |
@include font-black | Sets font-weight to 900 | None |
Line Height Mixins
Mixin | Description | Parameters |
---|---|---|
@include leading($value) | Sets line height | $value : Named value or number |
@include leading-none | Sets line height to 1 | None |
@include leading-tight | Sets line height to 1.25 | None |
@include leading-snug | Sets line height to 1.375 | None |
@include leading-normal | Sets line height to 1.5 | None |
@include leading-relaxed | Sets line height to 1.625 | None |
@include leading-loose | Sets line height to 2 | None |
Text Alignment Mixins
Mixin | Description | Parameters |
---|---|---|
@include text-left | Sets text-align to left | None |
@include text-center | Sets text-align to center | None |
@include text-right | Sets text-align to right | None |
@include text-justify | Sets text-align to justify | None |
Text Transform Mixins
Mixin | Description | Parameters |
---|---|---|
@include uppercase | Sets text-transform to uppercase | None |
@include lowercase | Sets text-transform to lowercase | None |
@include capitalize | Sets text-transform to capitalize | None |
@include normal-case | Sets text-transform to none | None |
Font Style Mixins
Mixin | Description | Parameters |
---|---|---|
@include italic | Sets font-style to italic | None |
@include not-italic | Sets font-style to normal | None |
Text Decoration Mixins
Mixin | Description | Parameters |
---|---|---|
@include underline | Sets text-decoration to underline | None |
@include line-through | Sets text-decoration to line-through | None |
@include no-underline | Sets text-decoration to none | None |
Text Overflow Mixins
Mixin | Description | Parameters |
---|---|---|
@include truncate | Truncates text with ellipsis in one line | None |
@include overflow-label | Handles overflow for labels with min-width support | None |
@include truncate-lines($lines) | Truncates text after specified number of lines | $lines : Number of lines to show before truncating |
Word Break Mixins
Mixin | Description | Parameters |
---|---|---|
@include break-normal | Sets normal word breaks | None |
@include break-words | Breaks words to prevent overflow | None |
@include break-all | Breaks words at any character | None |
Whitespace Mixins
Mixin | Description | Parameters |
---|---|---|
@include whitespace-normal | Sets white-space to normal | None |
@include whitespace-nowrap | Sets white-space to nowrap | None |
@include whitespace-pre | Sets white-space to pre | None |
@include whitespace-pre-line | Sets white-space to pre-line | None |
@include whitespace-pre-wrap | Sets white-space to pre-wrap | None |
Letter Spacing Mixins
Mixin | Description | Parameters |
---|---|---|
@include tracking($value) | Sets letter spacing | $value : Named value or direct value |
@include tracking-tighter | Sets letter spacing to -0.05em | None |
@include tracking-tight | Sets letter spacing to -0.025em | None |
@include tracking-normal | Sets letter spacing to 0 | None |
@include tracking-wide | Sets letter spacing to 0.025em | None |
@include tracking-wider | Sets letter spacing to 0.05em | None |
@include tracking-widest | Sets letter spacing to 0.1em | None |
Responsive Typography Mixin
Mixin | Description | Parameters |
---|---|---|
@include responsive-typography($breakpoint) | Generates responsive typography utilities | $breakpoint : Optional breakpoint name |
Example SCSS Usage
Best Practices
Semantic Typography
While utility classes are convenient, consider using semantic class names for common text patterns:
Font Size Accessibility
Remember to consider accessibility when selecting font sizes:
- Use relative units (rem) for better accessibility (NuvoUI's font sizes are in rem)
- Avoid font sizes smaller than
.text-sm
(0.875rem/14px) for body text - Maintain sufficient contrast between text and background colors
- Consider line height and spacing for readability
Responsive Typography
Use breakpoint-specific typography classes to adjust text properties at different screen sizes:
Performance Considerations
To keep your CSS bundle size smaller:
- If you're using many typography utility classes, consider using
@apply
or SCSS mixins instead - Only include the responsive variants you actually need
- Use appropriate truncation utilities to handle long text values