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.
tsimport {useThemeName} from '@astryxdesign/core/theme'
Best practices
| Guidance | Practices |
|---|---|
| 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
| Field | Type | Description |
|---|---|---|
| name | string | 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.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.bashnpx shadcn@4.19.0 add https://astryx-sdik3qwpg-fbopensource.vercel.app/shadcn/hooks/use-theme-name.json