# useSeedClassName URL: /lynx/hooks/use-seed-class-name Source: https://github.com/daangn/seed-design/blob/dev/docs/content/lynx/hooks/use-seed-class-name.mdx A hook that returns the theme className to apply to root `` and subscribes to theme changes. 사용 가능 버전: @seed-design/lynx-react@0.3.0 ## Import ```ts import { useSeedClassName } from "@seed-design/lynx-react"; ``` `useSeedClassName` is included in the `@seed-design/lynx-react` package. It's a reactive version of `getSeedClassName()`, subscribing to `lynx.__globalProps.theme` changes via `useGlobalProps()` and returning the updated className when the theme changes. ## Usage ### Basic Usage Apply to the root `` element. ```tsx import { root } from "@lynx-js/react"; import { useSeedClassName } from "@seed-design/lynx-react"; function Root() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( ); } root.render(); ``` ### `colorMode` Option | `colorMode` setting | Device setting | Theme class returned | | ------------------- | -------------- | ------------------------------ | | `system` (default) | Light mode | `seed-user-color-scheme-light` | | `system` | Dark mode | `seed-user-color-scheme-dark` | | `light-only` | (irrelevant) | `seed-user-color-scheme-light` | | `dark-only` | (irrelevant) | `seed-user-color-scheme-dark` | When `system`, it reads the `lynx.__globalProps.theme` value and follows the device's dark mode setting. ## How It Works `useSeedClassName()` internally subscribes to `lynx.__globalProps` via `useGlobalProps()`. When the host changes the theme, components using this hook re-render and return the className that matches the updated theme. The className mapping logic is identical to the pure function `getSeedClassName()`. The only difference is whether it subscribes to theme changes. - `useSeedClassName()`: A hook that subscribes to theme changes. Use it wherever you need to react to theme changes, such as the root ``. - `getSeedClassName()`: A pure function that reads the theme only once, at call time. Use it in static contexts that don't need to react to theme changes. On the web (React), a bundler plugin handles the theme automatically, but on Lynx, you subscribe explicitly with `useSeedClassName()`. See the [Theming](/lynx/getting-started/styling/theming) docs for the theme system overall. ## API ### Parameters | Property | Type | Default | Description | | ----------- | ----------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------- | | `colorMode` | `"system" \| "light-only" \| "dark-only"` | `"system"` | How the theme is determined. `system` follows the device setting; `light-only` / `dark-only` pin the theme. | ### Return | Type | Description | | -------- | ------------------------------------------------------------------------------------------- | | `string` | The theme class to apply (`seed-user-color-scheme-light` or `seed-user-color-scheme-dark`). | ## Usage Notes - Requires `@lynx-js/react` `0.117.0` or higher, since it depends on `useGlobalProps()`. - Being a hook, it can only be called from a component body. If you don't need to react to theme changes, use the pure function `getSeedClassName()` instead.