--- title: useValue description: "`useValue`は、`useBreakpointValue`と`useColorModeValue`を組み合わせたカスタムフックです。" links: - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/hooks/use-value - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/hooks-usevalue--basic --- ```tsx const breakpoint = useBreakpoint() const color = useValue({ base: "red", md: "green" }) return The current breakpoint is "{breakpoint}" ``` ```tsx const { colorMode } = useColorMode() const color = useValue(["green", "red"]) return The current colorMode is "{colorMode}" ``` ## 使い方 ```tsx import { useValue } from "@yamada-ui/react" ``` ```tsx import { useValue } from "@/components/ui" ``` ```tsx import { useValue } from "@workspaces/ui" ``` ```tsx const color = useValue({ base: "red", md: "green" }) ``` :::note `useValue`は、[useBreakpointValue](https://yamada-ui.com/hooks/use-breakpoint-value.md)と[useColorModeValue](https://yamada-ui.com/hooks/use-color-mode-value.md)を使用しています。 :::