Skip to Content
🎉 Coral now has an MCP Server, check out the docs
DocumentationAtomsTypography

Typography

Use the Typography component for all of your styled text needs

v48 Overhaul

New system

Unlike the previous Typography scales, the new Typography sizes and variants were created following modular scale principles.

We’ve chosen to base the scales on the Major Third for larger screen sizes, and the Minor Third for smaller screen sizes, and to round the values to the nearest multiple of 4.

We’re also standardising names across Coral platforms, so that you can use the same variant names across web and mobile.

A modular scale is a system for sizing typography and spaces where each size is calculated from a base size using a consistent ratio, it allows:

  • Visual harmony → No random size jumps
  • Consistent hierarchy → Proportional jumps help create consistent structure and information hierarchy
  • Scalability → Sizes can be extended give chosen base size and ratio
  • Responsive flexibility → Using different ratios to cater for smaller screens whilst reserving proportional relationships

Before

After

Lorem Ipsum

Lorem Ipsum

Lorem Ipsum

Lorem Ipsum

Lorem Ipsum

Lorem Ipsum
Lorem Ipsum

Lorem Ipsum

Lorem Ipsum

Lorem Ipsum

Lorem Ipsum

Lorem Ipsum

Lorem Ipsum

Lorem Ipsum

Deprecation

hero1, hero2, homepageTitle, h1, h2, h3, h4, h5, h6 are now deprecated, they will be removed in v48.

As TypeScript language servers don’t recognise deprecated string literals in union types (which textStyle is), you won’t see warnings when using these deprecated variants in your IDEs by default.

To solve this, upgrade your project to use the latest versions of @krakentech/eslint-config, @octopus-energy/biome or @octopus-energy/oxc which all includes inline deprecation warnings and automated fixes for your IDEs and CI pipelines. (Versions TBC)

Migration

For now, you can still use the old variants, but they are deprecated and will be removed in v48.

You can use the table below to see the mapping between old and new variants, and what the codemod does.

Current Figma variantv47 and older versions variantv48 variant
display1hero1, hero2, homepageTitledisplay1
display2h1display2
heading1h2heading1
heading2h3heading2
heading3h4heading3
title1h5title1
title2h6title2

You can also start using the standalone coral-typography-revamp codemod to automatically update your typography variants to the new variants.

npx @octopus-energy/codemods coral-typography-revamp <path-to-your-project>

Storyblok migration

You can start migrating your Storyblok content to use the new typography variants.

This is will the new variants to your datasources, and migrate your stories to use the new variants.

pnpm --package=@octopus-energy/coral-storyblok dlx storyblok-migration --migration coral-typography-revamp --spaceId <space-id> --accessToken <access-token>

Basic Usage

import { Typography } from '@octopus-energy/coral/atoms'; <Typography>The five boxing wizards jump quickly</Typography>

The five boxing wizards jump quickly

Properties

color

<Typography color="success500">The five boxing wizards jump quickly</Typography>

The five boxing wizards jump quickly

component

It may be you want the style of a Heading 2, but the semantics of a Display 1. In this case, you can use the component prop to change the underlying HTML element.

<Typography textStyle="heading2" component="h1"> The five boxing wizards jump quickly </Typography>

The five boxing wizards jump quickly

textAlign

<Typography textAlign="center">The five boxing wizards jump quickly</Typography>

The five boxing wizards jump quickly

textTransform

<Typography textTransform="uppercase">Wizard</Typography>

Wizard

textWrap

<Typography textWrap="balance"> Aliquip incididunt sunt dolore laborum aliquip cupidatat sint mollit commodo dolor. Aute cillum excepteur eu excepteur. Cupidatat cupidatat nostrud nisi dolore non. Aliqua amet nostrud aute aute exercitation voluptate eiusmod. Ea veniam elit quis eiusmod magna sunt irure velit consectetur veniam do sunt. Adipisicing deserunt commodo id et ullamco consequat. </Typography>

Aliquip incididunt sunt dolore laborum aliquip cupidatat sint mollit commodo dolor. Aute cillum excepteur eu excepteur. Cupidatat cupidatat nostrud nisi dolore non. Aliqua amet nostrud aute aute exercitation voluptate eiusmod. Ea veniam elit quis eiusmod magna sunt irure velit consectetur veniam do sunt. Adipisicing deserunt commodo id et ullamco consequat.

hyphens

<Typography hyphens="auto"> Aliquip incididunt sunt dolore laborum aliquip cupidatat sint mollit commodo dolor. Aute cillum excepteur eu excepteur. Cupidatat cupidatat nostrud nisi dolore non. Aliqua amet nostrud aute aute exercitation voluptate eiusmod. Ea veniam elit quis eiusmod magna sunt irure velit consectetur veniam do sunt. Adipisicing deserunt commodo id et ullamco consequat. </Typography>

Aliquip incididunt sunt dolore laborum aliquip cupidatat sint mollit commodo dolor. Aute cillum excepteur eu excepteur. Cupidatat cupidatat nostrud nisi dolore non. Aliqua amet nostrud aute aute exercitation voluptate eiusmod. Ea veniam elit quis eiusmod magna sunt irure velit consectetur veniam do sunt. Adipisicing deserunt commodo id et ullamco consequat.

textStyle

<Typography textStyle="heading2">The five boxing wizards jump quickly</Typography>

The five boxing wizards jump quickly

Variants

<Typography textStyle="display1">The five boxing wizards jump quickly</Typography> <Typography textStyle="display2">The five boxing wizards jump quickly</Typography> <Typography textStyle="heading1">The five boxing wizards jump quickly</Typography> <Typography textStyle="heading2">The five boxing wizards jump quickly</Typography> <Typography textStyle="heading3">The five boxing wizards jump quickly</Typography> <Typography textStyle="title1">The five boxing wizards jump quickly</Typography> <Typography textStyle="title2">The five boxing wizards jump quickly</Typography> <Typography textStyle="title3">The five boxing wizards jump quickly</Typography> <Typography textStyle="title4">The five boxing wizards jump quickly</Typography> <Typography textStyle="body1">The five boxing wizards jump quickly</Typography> <Typography textStyle="body2">The five boxing wizards jump quickly</Typography> <Typography textStyle="body3">The five boxing wizards jump quickly</Typography> <Typography textStyle="caption">The five boxing wizards jump quickly</Typography> <Typography textStyle="button">The five boxing wizards jump quickly</Typography> <Typography textStyle="code">const x = 1;</Typography> <Typography textStyle="kbd">Ctrl + C</Typography>

The five boxing wizards jump quickly

The five boxing wizards jump quickly

The five boxing wizards jump quickly

The five boxing wizards jump quickly

The five boxing wizards jump quickly

The five boxing wizards jump quickly

The five boxing wizards jump quickly
The five boxing wizards jump quickly
The five boxing wizards jump quickly

The five boxing wizards jump quickly

The five boxing wizards jump quickly

The five boxing wizards jump quickly

The five boxing wizards jump quickly

The five boxing wizards jump quickly
const x = 1;
Ctrl + C

Variants HTML mapping

textStyle variantUnderlying HTML element
display1<h1>
display2<h1>
heading1<h1>
heading2<h2>
heading3<h3>
title1<h4>
title2<h5>
title3<h6>
title4<h6>
body1<p>
body2<p>
body3<p>
button<span>
caption<p>
code<code>
kbd<kbd>
deprecated variants
hero1<h1>
hero2<h1>
homepageTitle<h1>
h1<h1>
h2<h2>
h3<h3>
h4<h4>
h5<h5>
h6<h6>

Responsiveness

color, textAlign and textStyle are all responsive variant props, which can be used as shown below.

Note that if textStyle is responsive, you will need to provide the component prop, for example:

<Typography textStyle={{ base: "body1", md: "body2" }} component="p">

The component prop becomes required here.

<Typography color={{ base: "primary500", lg: "secondary500" }} textAlign={{ base: "center", lg: "left" }} textStyle={{ base: "body2", lg: "body1" }} component="p" > color </Typography>

Responsive Element

Responsive sizes

Some textStyle variant already include responsive behaviour, so you might not need to use a responsive variant.

VariantBase font sizeBase font weightmd+ font sizemd+ font weight
display144px70056px700
display236px70044px700
heading132px50036px500
heading224px50028px500
heading320px50024px500
title118px500——
title216px500——
title314px500——
title412px500——
body118px400——
body216px400——
body314px400——
caption12px400——
button18px500——
code0.9em400——
kbd0.9em400——
deprecated variants
hero140px700144px700
hero240px70050px700
homepageTitle40px70050px700
h132px50040px500
h224px50036px500
h324px50028px500
h420px50022px500
h518px500——
h616px500——

Full API

NameTypeDefault
textStyleTypographyTextStyle | ResponsiveTypographyTextStyle

The typography variant to apply. The typography variant to apply as a responsive object. When using a responsive object, component is required because the element cannot be inferred from multiple breakpoint values.

body1
componentElementType

Overrides the element rendered. Combine this with the textStyle prop to control font sizing without sacrificing semantics. Required when textStyle is a responsive object, since the rendered element cannot be inferred from multiple breakpoint values.

childrenReactNode

The content to render inside the Typography component.

colorResponsiveVariant<"inherit" | "base20" | "base100" | "base200" | "base300" | "base500" | "base900" | "primary10" | "primary100" | "primary500" | "primary600" | "primary900" | "secondary10" | ... 67 more ... | "contentsInformation500">

The color of the text.

contentsBase900
directionConditionalValue<WithEscapeHatch<OnlyKnown<"direction", `var(--${string})` | Direction | readonly NonNullable<Direction | undefined>[] | undefined>>> | undefined

The CSS direction property to apply.

idstring

A unique identifier for this element.

overflowConditionalValue<WithEscapeHatch<OnlyKnown<"overflow", `var(--${string})` | Overflow | readonly string[] | undefined>>> | undefined

The CSS overflow property to apply.

textAlignResponsiveVariant<ConditionalValue<AnyString | TextAlign | readonly NonNullable<TextAlign | undefined>[] | undefined>>

The CSS text-align property to apply.

textOverflowConditionalValue<AnyString | readonly string[] | TextOverflow | undefined>

The CSS text-decoration property to apply.

textWrapConditionalValue<`var(--${string})` | AnyString | readonly string[] | TextWrap | undefined>

The CSS text-wrap property to apply.

whiteSpaceConditionalValue<AnyString | readonly string[] | WhiteSpace | undefined>

The CSS white-space property to apply.

wordBreakConditionalValue<WithEscapeHatch<OnlyKnown<"wordBreak", `var(--${string})` | WordBreak | readonly NonNullable<WordBreak | undefined>[] | undefined>>> | undefined

The CSS word-break property to apply.

textTransformConditionalValue<AnyString | readonly string[] | TextTransform | undefined>

The CSS word-spacing property to apply.

⚠︎ Use with caution. This property should be used for isolated words only.

htmlForstring

htmlFor attribute for when component is set to label.

hyphensConditionalValue<AnyString | Hyphens | readonly NonNullable<Hyphens | undefined>[] | undefined>

The CSS hyphens property to apply.

attributesAttributes

This prop can be used to pass HTML attributes directly to the component. We currently allow passing data-* and aria-* attributes and the id. However, you can pass anything else with a type hack if necessary since this object is despread in to the component, without filtering its content.

Example usage:

AttributesProps: { 'id': 'close-button', 'aria-label': 'Close button', 'data-testid': 'close-button' };
Last updated on