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 quicklyThe five boxing wizards jump quickly
The five boxing wizards jump quickly
The five boxing wizards jump quickly
const x = 1;Variants HTML mapping
textStyle variant | Underlying 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.
| Variant | Base font size | Base font weight | md+ font size | md+ font weight |
|---|---|---|---|---|
hero1 | 40px | 700 | 144px | 700 |
hero2 | 40px | 700 | 50px | 700 |
homepageTitle | 40px | 700 | 50px | 700 |
h1 | 32px | 500 | 40px | 500 |
h2 | 24px | 500 | 36px | 500 |
h3 | 24px | 500 | 28px | 500 |
h4 | 20px | 500 | 22px | 500 |
h5 | 18px | 500 | — | — |
h6 | 16px | 500 | — | — |
body1 | 18px | 400 | — | — |
body2 | 16px | 400 | — | — |
caption | 12px | 400 | — | — |
button | 18px | 500 | — | — |
code | 0.9em | 400 | — | — |
kbd | 0.9em | 400 | — | — |