Skip to main content

Typography

To ensure consistency, the Design System includes a set of typography styles that can be used in all components and products.

Values

We have CSS custom properties and 'Figma Variables' for font-size, line-height and font-weight.

Although you can style text using these directly, it is recommended to use our defined styles, as these apply the suggested font size + line-height pairings.

  • In Figma these are provided as 'Text styles'.
  • In development these are provided as scss mixins.

Style pairing / Typography mixins

stylefont-sizeline-height
style-0-5--font-size-0-5--line-height-0-75
style-0-75--font-size-0-75--line-height-1
style-1--font-size-1--line-height-1-5
style-1-5--font-size-1-5--line-height-1-5
style-2--font-size-2--line-height-2
style-3--font-size-3--line-height-2-5
style-4--font-size-4--line-height-3-5
style-5--font-size-5--line-height-4
style-6--font-size-6--line-height-4-5
style-7--font-size-7--line-height-5
style-8--font-size-8--line-height-6
style-9--font-size-9--line-height-6-5

font-size

PropertyValuepx eqv. (1rem = 16px)
--font-size-0-50.5rem8px
--font-size-0-750.75rem12px
--font-size-11rem16px
--font-size-1-51.25rem20px
--font-size-21.5rem24px
--font-size-32rem32px
--font-size-42.5rem40px
--font-size-53rem48px
--font-size-63.5rem56px
--font-size-74rem64px
--font-size-84.5rem72px
--font-size-95rem80px

line-height

PropertyValuepx eqv. (1rem = 16px)
--line-height-0-750.75rem12px
--line-height-11rem16px
--line-height-1-51.5rem24px
--line-height-22rem32px
--line-height-2-52.5rem40px
--line-height-33rem48px
--line-height-3-53.5rem56px
--line-height-44rem64px
--line-height-4-54.5rem72px
--line-height-55rem80px
--line-height-5-55.5rem88px
--line-height-66rem96px
--line-height-6-56.5rem104px

font-weight

PropertyValue
--font-weight-regular400
--font-weight-bold700

Implementation

Figma

If the Design System Library has been added to your file, these 'Text styles' should be available for you to apply to text elements.

Development

Load the typography mixins into your stylesheet:

@use "@raspberrypifoundation/design-system-core/scss/mixins/typography" as
typography;

Use the mixin in your styles:

.some-text {
@include typography.style-3;
}

.some-bold-text {
@include typography.style-3(bold);
}

More detailed development usage can be found in the Core Storybook.

Inspecting typography in Figma

In Figma 'Text styles" can be applied to text elements. 'Styles' in Figma can be thought of an equvialent to mixins as it combines a selection of styles.

For example, when the style-1 is applied to a text element the following Figma Variables (CSS custom properties) are applied:

  • Font family: font-family-primary
  • Font size: font-size-1
  • Line height: line-height-1-5
  • Font weight: font-weight-regular

So when inspecting a text element in Figma in dev mode, you will see a CSS code snippet that looks like this:

/* regular/style-1 */
font-family: var(--font-family-primary, Roboto);
font-size: var(--font-size-1, 1rem);
font-style: normal;
font-weight: var(--font-weight-regular, 400);
line-height: var(--line-height-1-5, 1.5rem);

The CSS comment shown at the top of the code snippet should be used to inform you of what mixin to use. So in this example, that would be:

.text {
@include typography.style-1;
}
info

regular/... appears in the CSS comments as this comment is generated using the the groups used in Figma to organise the 'Styles'. Unfortunately there is not currently better way for us to present this or a way to just provide a code snippet for the mixin.

Guidelines

Style pairings

In designs we try to use the style pairings where possible for consistency. However it is you can use custom pariring if the required, but still try to stick to using the predefined font-size and line-height variables.