--- title: useColorModeValue description: "`useColorModeValue`は、提供された値から現在のカラーモードの値を返すカスタムフックです。" links: - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/hooks/use-color-mode-value - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/hooks-usecolormodevalue--basic --- ```tsx const { colorMode } = useColorMode() const color = useColorModeValue("green", "red") return The current colorMode is "{colorMode}" ``` ## 使い方 ```tsx import { useColorModeValue } from "@yamada-ui/react" ``` ```tsx import { useColorModeValue } from "@/components/ui" ``` ```tsx import { useColorModeValue } from "@workspaces/ui" ``` ```tsx const color = useColorModeValue("green", "red") ``` :::tip カラーモードの概要は[こちら](https://yamada-ui.com/docs/styling/color-mode.md)をご覧ください。 :::