--- title: useBreakpointValue description: "`useBreakpointValue`は、提供されたオブジェクトから現在のブレイクポイントの値を返すカスタムフックです。このフックは、ウィンドウのサイズの変更を監視し、適切な値を返します。" links: - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/hooks/use-breakpoint - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/hooks-usebreakpointvalue--basic --- ```tsx const breakpoint = useBreakpoint() const bg = useBreakpointValue({ base: "red.500", sm: "purple.500", md: "yellow.500", lg: "green.500", xl: "blue.500", "2xl": "pink.500", }) return ( The current breakpoint is "{breakpoint}" ) ``` ## 使い方 ```tsx import { useBreakpointValue } from "@yamada-ui/react" ``` ```tsx import { useBreakpointValue } from "@/components/ui" ``` ```tsx import { useBreakpointValue } from "@workspaces/ui" ``` ```tsx const bg = useBreakpointValue({ base: "red.500", sm: "purple.500", md: "yellow.500", lg: "green.500", xl: "blue.500", "2xl": "pink.500", }) ```