Skip to main content
useTheme
@coinbase/cds-web@8.34.1
Returns the currently active theme including color schemes, spacing, typography, and other design tokens.
Import
import { useTheme } from '@coinbase/cds-web'
SourceView source code
Related components
View as Markdown

useTheme hook

The useTheme hook provides access to the current theme and activeColorScheme.

The color and spectrum objects automatically change based on the activeColorScheme.

const theme = useTheme();
theme.activeColorScheme; // "light" or "dark"
theme.spectrum; // Resolves to lightSpectrum or darkSpectrum, depends on activeColorScheme
theme.color; // Resolves to lightColor or darkColor, depends on activeColorScheme
theme.color.bgPrimary; // "rgb(0,82,255)" or "rgb(87,139,250)", depends on activeColorScheme
theme.space[2]; // 16
theme.borderRadius[200]; // 8
theme.fontSize.display3; // "2.5rem"
Tip

For best performance, prefer to use CSS Variables instead of the useTheme hook whenever possible. Read more about CSS Variables here →

Basic usage

Loading...

Styling with Theme values

Loading...

Color scheme detection

Loading...

Is this page useful?

Coinbase Design is an open-source, adaptable system of guidelines, components, and tools that aid the best practices of user interface design for crypto products.