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.
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.
mono-xl
mono-lg
mono-md
mono-sm
mono-xs
heading-2xs
button-sm
heading-2xl
heading-xl
heading-lg
heading-md
heading-sm
heading-xs
body-lg
body-md
body-sm
label-sm
button-md
label-md
display-lg
display-md
display-sm
link
Update the theme
To use the text styles, update the theme object with the textStyles
property.
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>