London City Data

Typography

Coherent and consistent use of type

Typography defines tone and ensures information is clear, legible, and consistent. Together with our spacing guidelines, it creates a balanced, accessible, and reliable user experience.

Use

The components already have the typography system applied.

For example if you use the title components like TitleGroup, DashboardTitle and PageTitle they handle setting the type on a title group for you.

<script>
	import { TitleGroup } from '@ldn-viz/ui';
</script>
 
<TitleGroup
	eyebrow="Air quality"
	title="Nitrogen dioxide"
	subtitle="Rolling 24-hour mean"
	headingLevel={3}
/>

Air quality

Nitrogen dioxide

Rolling 24-hour mean

Where you can't use a component and in your own markup you need to set your own type. The rest of this page explains how.

note: Some of the examples below use Tailwind utilities for color and padding. You don't need Tailwind to use the system.

Choose a typeset

Set the right typeset for the page or component you are building. There are two typesets: longform for reading, and product for interfaces, tables, charts and maps.

The typeset dictates the size and spacing behaviour of its children.

Set by adding a class to a containing element. Where typesets are nested the inner one applies.

<article class="typeset-longform">
	<p class="body-md">Set by the longform typeset</p>
	<div class="typeset-product">
		<p class="body-md">Set by the product typeset</p>
	</div>
</article>

Read more detail about how typesets work

Give text a role

The system describes type by role. A role names the job a piece of text does; an article headline, an input label, the title of a chart, and dictates every property that job requires: font family, size, weight, line height and letter spacing.

Each role's job, sizes and weight are listed under Roles.

Roles are applied by giving the element a class that corresponds to the role.

<h3 class="title-lg">The large title role</h3>

The closest typeset context then applies values to the roles properties: font family, size, weight, line height and letter spacing.

<article class="typeset-longform">
	<p class="body-md">The medium body title role. Properties set by the longform typeset</p>
</article>
 
<article class="typeset-product">
	<p class="body-md">The medium body title role. Properties set by the product typeset</p>
</article>

The medium body title role. Properties set by the longform typeset

The medium body title role. Properties set by the product typeset

The product typeset applies a tighter line height on this role

Formatted content

In some situations like rendering Markdown or content from a CMS, it might not be possible to add classes to every element on the page. Inside typeset-longform and typeset-product--formatted plain html is styled without the need for direct role classes. A class on the element replaces its default style.

<div class="typeset-product--formatted">
	<h3>About this data</h3>
	<p>Counts are provisional until the annual release.</p>
	<ul>
		<li>Source: GLA City Intelligence</li>
		<li>Updated quarterly</li>
	</ul>
	<p class="body-sm">Style over-ride</p>
</div>

About this data

Counts are provisional until the annual release.

  • Source: GLA City Intelligence
  • Updated quarterly

Style over-ride

See the reference for the styling that is applied per element.

Content width

In a formatted typeset, running text is limited to 38 times the body size, which is 608px at a 16px body size. Figures, images, videos, tables, code blocks and charts can be up to 56 times the body size (896px). To set a block's width directly, use width-content, width-content-wide or width-content-full.

width-content-full
width-content-wide
width-content

Escaping the style

To turn the styling off, for example around an embedded component that has its own styles, add not-typeset to a block or to a single element. The styling also stops at a typeset nested inside.

<div class="typeset-longform">
	<h3>Title</h3>
	<div class="not-typeset">
		<h3>I have escaped</h3>
	</div>
	<h3 class="not-typeset">So have I</h3>
</div>

Title

I have escaped

So have I

Usage aliases

The system provides a set of pre-defined usage alias classes. These are classes that are named for where they are applied.

Aliases are named {place}-{part}, for example .card-title, .chart-tick and .dashboard-section-title.

<h3 class="chart-title">A chart title</h3>
<p class="chart-subtitle">and its subtitle</p>

A chart title

and its subtitle

These are a convenience. Each alias applies a role, and some also add the muted text colour or tabular numerals. Use a role class where you can, because the roles are the system's stable API.

Check the reference section for the full set of classes.

Title groups

A title group is the text at the top of a card, chart, table or panel. It has up to three parts, in this order: an optional eyebrow, a title and an optional subtitle. Write the parts as sibling elements, each with its role:

<section class="typeset-product flow-standard">
	<p class="eyebrow">Air quality</p>
	<h2 class="title-md">Nitrogen dioxide</h2>
	<p class="subtitle-sm">Rolling 24-hour mean</p>
</section>

Air quality

Nitrogen dioxide

Rolling 24-hour mean

Card, ChartContainer and TitleGroup components set this with their emphasis prop. Surfaces and chrome has more examples.

Colour and emphasis

Set text colour with a semantic token:

<p class="body-md text-color-text">Primary text</p>
<p class="body-sm text-color-text-muted">Secondary text</p>
<span class="label-md text-color-label">Control label</span>

Primary text

Secondary text

Control label

The text tokens are --color-text and --color-text-muted, from most to least emphasis. The label tokens are --color-label and --color-label-muted. Text or an icon on a filled control uses an inverse token, such as --color-inverse-text, so that it contrasts with the fill in light and dark mode.

Subhead, subtitle, eyebrow and the lead paragraph are muted by the system.

See the foundation section on colour for more.

To emphasise text within a role, add text-strong, which sets semibold. text-soft sets regular.

<p class="body-md">Readings are <span class="text-strong">provisional</span>.</p>

Readings are provisional.

Things to avoid

  • Tailwind type utilities such as text-xl, font-bold and leading-tight. The preset removes them. Use a role, or text-strong and text-soft for weight.
  • Setting a size per breakpoint. Each role already has a value for every breakpoint.
  • Adding a weight to a role to change its look. Use text-strong or text-soft.
  • Mixing typesets in one region. Give reading content in an application its own typeset-product--formatted or typeset-longform container.
  • Using the type scale directly, including inside a component. Use a role.

How it works

Typeface

We use the sans serif font Inter. Inter is a variable font family designed for computer screens, available via Google Fonts under the Open Font License. By using webfonts in our applications we can be reasonably certain that Inter will be used under normal circumstances. All weights are included, so there is no risk of a browser synthesising a bold or a semibold from a lighter face, which produces a coarser letterform than the designed one.

If Inter fails to load, text falls back through this stack:

ui-sans-serif,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto
Color Emoji"

Type scale

Every size comes from a scale of 17 steps. Step 0 is 16px, the body size.

StepSizeSample
1472pxAg
1364pxAg
1256pxAg
1148pxAg
1040pxAg
936pxAg
832pxAg
730pxAg
628pxAg
526pxAg
424pxAg
322pxAg
220pxAg
118pxAg
016pxAg
-114pxAg
-212pxAg

Designs and code use the roles, which take their sizes from the scale.

Generative logic

The scale is built from five base sizes: 12, 14, 16, 18, (doubled twice) and 20 (doubled once)

Doubling chains:

  • 12 → 24 → 48
  • 14 → 28 → 56
  • 16 → 32 → 64
  • 18 → 36 → 72
  • 20 → 40 (→ 80 if extended)

22, 26 and 30 belong to no chain. They are hand-placed values, included in the lower half of the scale as intermediate sizes for responsive type. Below 32px, each step is about 1.07 to 1.17 times the one before (12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32). The close steps give fine control at interface sizes, where a small difference in size is easier to see than it is at display sizes.

Extending the scale:

  • Above step 14 (72px): extend the doubling chain — 40 → 80, 48 → 96, 56 → 112 etc.
  • Below step -2 (12px): continue the dense-region ratio, giving the next step ≈ 11px.

Typesets

The system has two typesets: longform for reading, and product for interfaces, tables, charts and maps. Both use the same roles. A typeset gives a role its font, weight, line height, letter-spacing or size. Longform is airier, which suits long passages of text, and product is tighter, which suits dashboards.

ClassForFlow contextContent styles and widths
typeset-longformArticles, reports and documentationflow-spaciousYes
typeset-productInterfaces, tables, charts and mapsNoneNo
typeset-product--formattedContent from a CMS or Markdown in a product settingflow-standardYes

typeset-longform and typeset-product--formatted set the vertical spacing through flow. typeset-product sets type only, and can be combined with a flow class as required.

The typeset is chosen once, on a wrapper or app root:

<div class="typeset-longform"></div>

where contexts are nested the inner context takes precedence:

<article class="typeset-longform">
	<p class="body-md">I am set by the longform typeset</p>
	<div class="typeset-product">
		<p class="body-md">I am set by the product typeset</p>
	</div>
</article>

Product is the default typeset. Its role values are also set on :root, so a role class outside any typeset still works.

Roles

A role names the job a piece of text does, such as the label on an input or the title of a card. If card titles need to be a step larger, the change is made to the role and every card title changes with it.

There are ten roles:

Example

Usage

Display
High-impact text, such as a homepage hero. Use sparingly.
Headline
The main statement of a page or a major section.
Subhead
A supporting line under a headline or display.
Title
The name of a unit within the page: a card, panel, chart, table or block of prose.
Subtitle
A supporting line under a title.
Body
Running text.
Label
Text needed to use the interface: buttons, inputs, tabs.
1,284
Metric: a figure shown as the content itself.
Caption
Optional notes: image and chart captions, sources, helper text.
Eyebrow
A short signpost above a headline or title.

Each role comes in three sizes, sm, md and lg, except eyebrow, which has one. No title is smaller than 18px, so a heading in a small container, such as a popover or a sidebar section, can use label-lg.

Labels and eyebrows are medium (500), titles are semibold (600), and display, headlines and metrics are bold (700). Other roles are regular (400). Metrics use tabular numerals.

Font weight

The system has five font weights.

WeightNumeral
Light300
Regular400
Medium500
Semibold600
Bold700

Identity weight vs emphasis weight

  • Identity weight is attached to role within a typeset
  • Emphasis weight is a separate modifier that can be applied as an over-ride to give emphasis.

Per-role identity weights

Both typesets give each role the same weight.

RoleWeight
DisplayBold (700)
HeadlineBold (700)
SubheadRegular (400)
TitleSemibold (600)
SubtitleRegular (400)
BodyRegular (400)
LabelMedium (500)
MetricBold (700)
CaptionRegular (400)
EyebrowMedium (500)

Line height

Line height is defined in three steps based on a simple formula: font-size + k, where font-size and k are measured in px.

tightdefaultloose
font-size + 4pxfont-size + 8pxfont-size + 12px

Line height comes from the role. There are no line-height utilities.

Responsive sizing

Some roles grow as the screen widens. The breakpoints are sm (640px), md (768px), lg (1024px) and xl (1280px). Type at wider screens stays at the xl size.

These roles change size, in pixels:

RoleTypesetbasesmmdlgxl
display-lgBoth4048566472
display-mdBoth3640485664
display-smBoth3236404856
headline-lgLongform3032364040
headline-lgProduct3032363640
headline-mdLongform2828303232
headline-mdProduct2828303030
headline-smLongform2626283030
subhead-lgLongform2424242626
subhead-mdLongform2222222424
title-lgLongform2222222424
body-lgLongform1818202020
metric-lgBoth2830323236

Every other role has one size at every breakpoint.

Reference

Choose a typeset and a breakpoint to see the values for each role.

product
base

Each value is the token --typography-base-product-{role}-{property}.

Rolefont-sizeline-heightfont-weightletter-spacing
display-lg40px48px7000px
display-md36px44px7000px
display-sm32px40px7000px
headline-lg30px38px7000px
headline-md28px36px7000px
headline-sm26px34px7000px
subhead-lg24px32px4000px
subhead-md22px30px4000px
subhead-sm20px28px4000px
title-lg22px30px6000px
title-md20px28px6000px
title-sm18px26px6000px
subtitle-lg20px28px4000px
subtitle-md18px26px4000px
subtitle-sm16px24px4000px
body-lg18px26px4000px
body-md16px24px4000px
body-sm14px22px4000px
label-lg18px26px5000px
label-md14px22px5000px
label-sm12px20px5000px
metric-lg28px32px7000px
metric-md24px28px7000px
metric-sm20px24px7000px
eyebrow14px18px5000px
caption-sm12px16px4000px
caption-md14px18px4000px
caption-lg16px20px4000px

Formatted content

In a typeset-longform or typeset-product--formatted: Headings, the lead paragraph, quotes and captions take these roles:

ElementRole
h1headline-lg
h2headline-sm
h3title-lg
h4title-md
h5title-sm
p.leadbody-lg, muted
figcaptioncaption-sm, muted
blockquotesubtitle-md, muted, with a brand-colour rule on the left
citecaption-md, muted, upright
Any other textbody-md

Other elements keep the role of the text around them, with these changes:

ElementStyle
aLink colour, underlined. The underline thickens on hover
strong, bSemibold
em, iItalic
markMuted caution background
abbrHelp cursor, when it has a title
small0.875 times the surrounding size
code0.875 times the surrounding size, on a muted surface
kbdAs code, with a border
  • ul
Disc markers, then circle and square when nested. Markers are muted
  1. ol
Numbers, then letters and roman numerals when nested
dt
dd
Term semibold, description indented
pre
Muted surface, scrolls sideways when too wide
summarydetails
Summary semibold
tableFull width. Caption muted and above, header cells semibold, figures in tabular numerals, rules between rows
hrWash border colour

Usage aliases

A usage alias is a class named for the place it is used, such as card-title or chart-tick. Each alias applies a role, and some also add the muted text colour or tabular numerals.

Charts

SampleAliasRoleAdds
Chart titlechart-titletitle-md–
Chart subtitlechart-subtitlesubtitle-smMuted colour
Axis titlechart-axis-titlelabel-mdMuted colour
Data labelchart-labellabel-md–
2024chart-tickcaption-mdMuted colour, tabular numerals
2024chart-tick-smcaption-smMuted colour, tabular numerals
Source: GLAchart-notecaption-sm–

chart-label is for value labels, annotations and legend entries. chart-tick-sm is for the ticks of a dense chart.

Tables

SampleAliasRoleAdds
Table titletable-titletitle-md–
Table subtitletable-subtitlesubtitle-smMuted colour
Column headertable-col-headlabel-mdTabular numerals
Column headertable-col-head-smlabel-smTabular numerals
1,284table-bodybody-smTabular numerals

Interface

SampleAliasRoleAdds
Dashboard titledashboard-main-titleheadline-md–
Dashboard subtitledashboard-main-subtitlesubhead-mdMuted colour
Section titledashboard-section-titleheadline-sm–
Section subtitledashboard-section-subtitlesubhead-smMuted colour
Header titleheader-titletitle-md–
Sidebar titlesidebar-titletitle-md–
Dialog titledialog-titlelabel-lg–
Card titlecard-titletitle-md–
Card subtitlecard-subtitlesubtitle-smMuted colour
Input labelinput-labellabel-md–
Placeholderinput-placeholderbody-md–
Field valueinput-valuebody-md–
Hint textinput-hintcaption-sm–
Button labelbutton-labellabel-md–
Button labelbutton-label-smlabel-sm–

Controls such as buttons, tabs and chips use the label role's line height. Their padding sets their height.

The full rules for type are in the specification.