Leave Yamada UI a star

Star
Yamada UIYamada UIv1.6.4

useValue

useValue is a custom hook that combines useBreakpointValue and useColorModeValue.

Source@yamada-ui/use-value

Import

import { useValue } from "@yamada-ui/react"
Copied!

Usage

Editable example

const { colorMode } = useColorMode()
const breakpoint = useBreakpoint()
const bg = useValue({
  base: "red.500",
  xl: "blue.500",
  lg: "green.500",
  md: "yellow.500",
  sm: "purple.500",
})
const color = useValue(["whiteAlpha.800", "blackAlpha.800"])

return (
  <Box
    bg={bg}
    p="md"
    rounded="md"
    color={color}
    transitionProperty="all"
    transitionDuration="slower"
  >
    The current breakpoint is "{breakpoint}", colorMode is "{colorMode}"
  </Box>
)
Copied!

Edit this page on GitHub

PrevioususeUpdateEffectNextuseWindowEvent