AI Assistant

Typography

Every text style in the Cherry type scale is available as a CSS mixin. Each helper takes the theme and returns the responsive font-size and line-height for its style: the mobile (xs) values apply as the base, and the desktop (lg) values kick in from the lg breakpoint (992px by default) via the mq() media query helper. Interpolate a helper into any styled component to give one element the type of another - the classic case is an h2 that should look like an h1:

import styled from "styled-components";
import { styledH1 } from "cherry-styled-components";

const SectionTitle = styled.h2`
  ${({ theme }) => styledH1(theme)}
`;

The values are read from theme.fontSizes and theme.lineHeights, so any overrides in a custom Theme flow through automatically. The full scale with design specs lives on the Typography page.

Helpers

Sizes below are shown as font-size / line-height for the xs and lg values of the default theme.

Hero

HelperTheme keyXSLG
styledHero1hero172px / 1.10128px / 1.10
styledHero2hero260px / 1.1096px / 1.10
styledHero3hero336px / 1.2072px / 1.10

Headings

HelperTheme keyXSLG
styledH1h140px / 1.5060px / 1.40
styledH2h230px / 1.5036px / 1.50
styledH3h328px / 1.3030px / 1.50
styledH4h426px / 1.3024px / 1.50
styledH5h518px / 1.6020px / 1.50
styledH6h616px / 1.6018px / 1.60

Text

HelperTheme keyXSLG
styledTexttext14px / 1.7016px / 1.70
styledStrongstrong14px / 1.7016px / 1.70
styledSmallsmall12px / 1.7014px / 1.70
styledBlockquoteblockquote16px / 1.7018px / 1.70
styledCodecode14px / 1.7016px / 1.70

Controls

HelperTheme keyXSLG
styledButtonbutton16px / 1.0016px / 1.00
styledButtonBigbuttonBig18px / 1.0018px / 1.00
styledInputinput16px / 1.0016px / 1.00
styledInputBiginputBig18px / 1.0018px / 1.00

The helpers set only font-size and line-height. Font-weight and font-family are not included, so heading weights come from the browser's bold defaults for h1 to h6 unless you set font-weight yourself.

createTypographyStyle

All of the helpers above are built with the createTypographyStyle factory. It takes a key of the theme's FontSizes interface and returns a (theme: Theme) => css function that outputs the responsive declarations for that key. The theme scale also includes buttonSmall and inputSmall keys that have no prebuilt helper - use the factory to cover those:

import styled from "styled-components";
import { createTypographyStyle } from "cherry-styled-components";

const styledButtonSmall = createTypographyStyle("buttonSmall");

const TinyLabel = styled.span`
  ${({ theme }) => styledButtonSmall(theme)}
`;