Skip to Content
🎉 Coral x Panda has been released 🎉 Read the Migration Guide
DocumentationAtomsTypography

Typography

Use the Typography component for all of your styled text needs

Basic Usage

import { Typography } from '@krakentech/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 1, but the semantics of a Heading 2. In this case, you can use the component prop to change the underlying HTML element.

<Typography textStyle="h1" component="h2"> 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="h3">The five boxing wizards jump quickly</Typography>

The five boxing wizards jump quickly

Variants

<Typography textStyle="hero1">The five boxing wizards jump quickly</Typography> <Typography textStyle="hero2">The five boxing wizards jump quickly</Typography> <Typography textStyle="h1">The five boxing wizards jump quickly</Typography> <Typography textStyle="h2">The five boxing wizards jump quickly</Typography> <Typography textStyle="h3">The five boxing wizards jump quickly</Typography> <Typography textStyle="h4">The five boxing wizards jump quickly</Typography> <Typography textStyle="h5">The five boxing wizards jump quickly</Typography> <Typography textStyle="h6">The five boxing wizards jump quickly</Typography> <Typography textStyle="button">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="caption">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

const x = 1;
Ctrl + C

Variants HTML mapping

textStyle variantUnderlying HTML element
body1<p>
body2<p>
button<span>
caption<p>
h1<h1>
h2<h2>
h3<h3>
h4<h4>
h5<h5>
h6<h6>
homepageTitle<h1>
hero1<h1>
hero2<h1>
code<code>
kbd<kbd>

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
hero140px700144px700
hero240px70050px700
homepageTitle40px70050px700
h132px50040px500
h224px50036px500
h324px50028px500
h420px50022px500
h518px500——
h616px500——
body118px400——
body216px400——
caption12px400——
button18px500——
code0.9em400——
kbd0.9em400——

Full API

NameTypeDefault
textStyle"hero1" | "hero2" | "homepageTitle" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "body1" | "body2" | "caption" | "button" | "link" | "code" | "kbd" | 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" | ... 57 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