Leave Yamada UI a star

Star
Yamada UIYamada UIv1.7.2

Fade

Fade is a component that gradually shows or hides an element.

Source@yamada-ui/transitions

Import

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

Usage

To control the visibility, set isOpen.

Editable example

const { isOpen, onToggle } = useDisclosure()

return (
  <>
    <Button onClick={onToggle}>Please Click</Button>

    <Fade isOpen={isOpen}>
      <Box w="full" bg="orange.500" rounded="md" p="md" color="white" mt="md">
        クリリンのことか……クリリンのことかーーーっ!!!!!
      </Box>
    </Fade>
  </>
)
Copied!

Change the Duration

To change the duration, set a number (in seconds) to duration.

Editable example

const { isOpen, onToggle } = useDisclosure()

return (
  <>
    <Button onClick={onToggle}>Please Click</Button>

    <Fade isOpen={isOpen} duration={0.4}>
      <Box w="full" bg="orange.500" rounded="md" p="md" color="white" mt="md">
        クリリンのことか……クリリンのことかーーーっ!!!!!
      </Box>
    </Fade>
  </>
)
Copied!

Unmount on Exit

To unmount the component when it is not visible, set unmountOnExit to true.

Editable example

const { isOpen, onToggle } = useDisclosure()

return (
  <>
    <Button onClick={onToggle}>Please Click</Button>

    <Fade isOpen={isOpen} unmountOnExit>
      <Box w="full" bg="orange.500" rounded="md" p="md" color="white" mt="md">
        クリリンのことか……クリリンのことかーーーっ!!!!!
      </Box>
    </Fade>
  </>
)
Copied!

Edit this page on GitHub

PreviousCollapseNextFlip