useThemeName@astryxdesign/core v0.7.15 · useThemeName

Usage

Reads only the active theme name. Use it when code needs to know which theme is on, and does not need tokens or the color mode. It reads ThemeContext when a Theme is above the caller, and otherwise the root theme name on the document element.

ts
import {useThemeName} from '@astryxdesign/core/theme'

Best practices

GuidancePractices
Do

Use this hook for theme identity, such as picking a semantic icon for the active theme.

Do

Use useTheme when the caller also needs token values or the resolved light or dark mode.

Don't

Treat null as the name default. Null means no theme name is available.

Returns

FieldTypeDescription
namestring | null

The nearest Theme name. Null when no Theme context is present and the root has not set a theme name.

Examples

Common configurations, variations, and states.
useThemeName — Active theme
Open in Playground

The name of the theme around the caller, read with useThemeName. The card is inside a theme named harbor.

Use with shadcn

Already using the shadcn registry workflow? Install the real Astryx package and a local public re-export. Component implementation source stays in Astryx.

This install URL expires with the draft preview.
bash
npx shadcn@4.19.0 add https://astryx-lik2s0rsl-fbopensource.vercel.app/shadcn/hooks/use-theme-name.json