DirectiveUpdated in v15Optional

wrTypography

Style any text element with a shared text role.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrTypography } from 'ngwr/typography';

@Component({ imports: [WrTypography] })
export class MyComponent {}

Selector

Put it on the element you already have and pick a variant.

ngwr/typography

The directive styles what it sits on

Semantics stay yours — a heading is still an <h1>, a list still a <ul>.

Inputs

NameDescriptionTypeDefault
variantThe text role: size, weight, leading and, for some variants, colour.WrTypographyVariant'body'
toneColour override. null keeps the variant colour; base turns a muted variant to the page ink.WrTypographyTone | nullnull
alignText alignment. null inherits it.WrTypographyAlign | nullnull
truncateOne line with an ellipsis. Sets display: inline-block.booleanfalse
monoMonospace font. On by default for variant="code".booleanfalse

Variants

Some variants have their own colour, which tone overrides.

NameDescriptionTypeDefault
displayHero headline. The only fluid size.clamp(--wr-text-4xl, 6vw, 3.75rem)—
h1 … h6The heading ladder.--wr-text-5xl … --wr-text-lg—
leadIntro paragraph under a heading.--wr-text-xl · muted—
bodyDefault. Running text.--wr-text-base—
smallSmall print.--wr-text-sm—
captionCaptions, helper text.--wr-text-xs · muted—
overlineSection label above a heading.--wr-text-xs · uppercase · muted—
codeInline code. Implies mono.tinted inline chip · 0.875em—
listPut it on the ul, ol or dl itself.ul / ol / dl aware · muted—
linkInline link styling.primary—

Emitted classes

Target these from your own stylesheet.

NameDescriptionTypeDefault
wr-typographyBase class. Sets margin, font family, and --wr-color-on-surface.always—
wr-typography--{variant}One per variant.always—
wr-typography--tone-{tone}Absent when tone is null.when `tone` is set—
wr-typography--align-{align}Absent when align is null.when `align` is set—
wr-typography--truncateAdds the ellipsis clamp.when `truncate`—
wr-typography--monoMonospace font.when `mono` or `variant="code"`—

CSS variables

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/typography's own element.

VariableDefaultDeclared on
--wr-typeset-bodylight-dark(var(--wr-color-gray-700), var(--wr-color-gray-300)).wr-typeset
--wr-typeset-boldvar(--wr-color-primary-ink).wr-typeset
--wr-typeset-bulletsvar(--wr-color-primary).wr-typeset
--wr-typeset-captionslight-dark(var(--wr-color-gray-500), var(--wr-color-gray-400)).wr-typeset
--wr-typeset-codevar(--wr-color-on-surface).wr-typeset
--wr-typeset-counterslight-dark(var(--wr-color-gray-500), var(--wr-color-gray-400)).wr-typeset
--wr-typeset-headingsvar(--wr-color-on-surface).wr-typeset
--wr-typeset-hrlight-dark(var(--wr-color-gray-200), var(--wr-color-gray-700)).wr-typeset
--wr-typeset-leadlight-dark(var(--wr-color-gray-600), var(--wr-color-gray-400)).wr-typeset
--wr-typeset-linksvar(--wr-color-on-surface).wr-typeset
--wr-typeset-pre-bgvar(--wr-color-fill).wr-typeset
--wr-typeset-quote-borderslight-dark(var(--wr-color-gray-200), var(--wr-color-gray-700)).wr-typeset
--wr-typeset-quotesvar(--wr-color-on-surface).wr-typeset
--wr-typeset-td-borderslight-dark(var(--wr-color-gray-200), var(--wr-color-gray-700)).wr-typeset
--wr-typeset-th-borderslight-dark(var(--wr-color-gray-300), var(--wr-color-gray-600)).wr-typeset
--wr-typography-font-familyvar(--wr-font-family-base).wr-typography +2 variant overrides
--wr-typography-font-sizevar(--wr-text-base).wr-typography +13 variant overrides
--wr-typography-font-weightvar(--wr-font-weight-regular).wr-typography +11 variant overrides
--wr-typography-letter-spacingvar(--wr-tracking-normal).wr-typography +4 variant overrides
--wr-typography-line-heightvar(--wr-leading-normal).wr-typography +12 variant overrides
--wr-typography-list-dd-font-sizevar(--wr-text-lg).wr-typography
--wr-typography-list-dd-font-weightvar(--wr-font-weight-medium).wr-typography
--wr-typography-list-dt-bordervar(--wr-border-base).wr-typography
--wr-typography-list-dt-margin-bottomvar(--wr-space-xs).wr-typography
--wr-typography-list-dt-margin-topvar(--wr-space-md).wr-typography
--wr-typography-list-dt-padding-topvar(--wr-space-md).wr-typography
--wr-typography-list-margin-topvar(--wr-space-xs).wr-typography
--wr-typography-list-padding-startvar(--wr-space-xl).wr-typography
--wr-typography-padding-x0.wr-typography +1 variant override
--wr-typography-padding-y0.wr-typography +1 variant override
--wr-typography-radiusvar(--wr-border-radius-sm).wr-typography

See also