Text Styles
Learn how to customize text styles.
Overview
Text styles are tokens that are used to reuse text styles across the project.
The text styles defined in the theme can be found in the source code.
Mono
<Text textStyle="mono">Mono</Text>
export const textStyles = defineStyles.textStyle({
ghost: {
color: "colorScheme.outline",
},
mono: {
fontFamily: "mono",
fontWeight: "medium",
letterSpacing: "widest",
whiteSpace: "nowrap",
},
outline: {
color: "colorScheme.outline",
},
solid: {
color: "colorScheme.contrast",
},
subtle: {
color: "colorScheme.fg",
},
surface: {
color: "colorScheme.fg",
},
})
Customize
- 1
Generate a Theme
Use the CLI to generate a theme.
Before running the following commands, you need to install@yamada-ui/cliand execute theinitcommand. For more details, please see the CLI.pnpm yamada-cli themenpm yamada-cli themeyarn yamada-cli themebun yamada-cli theme - 2
Change the Style
Change the
styles/text-styles.tsin the generated theme.theme/styles/text-styles.ts
import { defineStyles } from "@yamada-ui/react" export const textStyles = defineStyles.textStyle({ gradient: { bgClip: "text", bgGradient: "linear(to-l, #7928CA, #FF0080)", fontSize: "5xl", w: "full", }, ghost: { color: "colorScheme.outline", }, mono: { fontFamily: "mono", fontWeight: "medium", letterSpacing: "widest", whiteSpace: "nowrap", }, outline: { color: "colorScheme.outline", }, solid: { color: "colorScheme.contrast", }, subtle: { color: "colorScheme.fg", }, surface: { color: "colorScheme.fg", }, }) - 3
Update the Provider
Set the generated theme to
UIProvider.import { UIProvider } from "@workspaces/ui" import { theme } from "@workspace/theme" const App = () => { return ( <UIProvider theme={theme}> <YourApplication /> </UIProvider> ) } - 4