Text Styles

Learn how to use text styles to define typography related properties.

Overview

Text styles allows you to define textual css properties. The common properties are:

  • Font: font family, weight, size
  • Line height
  • Letter spacing
  • Text decoration
  • Text transform

Defining text styles

Text styles are defined using the defineTextStyles function.

text-styles.ts
import { defineTextStyles } from "@pandacss/dev"
export const textStyles = defineTextStyles({
body: {
description: "The body text style - used in paragraphs",
value: {
fontFamily: "Inter",
fontWeight: "500",
fontSize: "16px",
lineHeight: "24",
letterSpacing: "0",
textDecoration: "None",
textTransform: "None",
},
},
})

Built-in text styles

Cerberus provides a set of built-in text styles.

  • display-lg

  • display-md

  • display-sm

  • heading-2xl

  • heading-xl

  • heading-lg

  • heading-md

  • heading-sm

  • heading-xs

  • heading-2xs

  • body-lg

  • body-md

  • body-sm

  • label-sm

  • label-md

  • button-md

  • button-sm

  • mono-xl

  • mono-lg

  • mono-md

  • mono-sm

  • mono-xs

  • link

Update the theme

To use the text styles, update the theme object with the textStyles property.

panda.config.ts
import {
createCerberusConfig,
createCerberusPreset,
} from '@cerberus/panda-preset'
import { textStyles } from "./text-styles"
export default createCerberusConfig({
presets: [createCerberusPreset()],
include: ['./app/**/*.{ts,tsx}'],
exclude: [],
theme: {
extend: {
textStyles,
},
}
})

Using text styles

Now you can use textStyle property in your components.

<Box textStyle="body">This is the body text style</Box>