apps/www/content/docs/styling/text-styles.mdx
Text styles allows you to define textual css properties. The common properties are:
Text styles are defined using the defineTextStyles function.
import { defineTextStyles } from "@chakra-ui/react"
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",
},
},
})
Chakra UI provides a set of built-in text styles.
<ExamplePreview name="tokens/text-styles" />To use the text styles, update the theme object with the textStyles
property.
import { createSystem, defineConfig } from "@chakra-ui/react"
import { textStyles } from "./text-styles"
const config = defineConfig({
theme: {
textStyles,
},
})
export default createSystem(defaultConfig, config)
After updating the theme, run the typegen command to generate the typings. See the CLI docs for how to run typegen in postinstall, CI, and monorepos.
npx @chakra-ui/cli typegen
Now you can use textStyle property in your components.
<Box textStyle="body">This is the body text style</Box>