useToken
useToken
is a custom hook used to resolve design tokens from the theme.
Import#
import { useToken } from "@chakra-ui/react"
Return value#
The useToken
hook retrieves whatever is in the theme at the given path(s).
Usage#
function Example() {
const [red100, blue200] = useToken(
"colors",
["red.100", "blue.200"],
)
return (
<Box bg={`linear-gradient(${red100}, ${blue200})`}>
<Text color="black">wonderful gradients</Text>
</Box>
)
}
Editable Example