Flip
Flip is a component that provides an animation to switch between two elements while flipping.
<Flip
aria-label="Toggle icon"
from={<AppleIcon fontSize="2xl" />}
to={<CherryIcon fontSize="2xl" />}
/>
Usage
import { Flip } from "@yamada-ui/react"
import { Flip } from "@/components/ui"
import { Flip } from "@workspaces/ui"
<Flip />
Change Direction
To change the direction, set orientation to "horizontal" or "vertical". By default, "horizontal" is set.
<Flip
aria-label="Toggle icon"
orientation="vertical"
from={<AppleIcon fontSize="2xl" />}
to={<CherryIcon fontSize="2xl" />}
/>
Change the Duration
To change the duration, set a numerical value (seconds) to duration.
<Flip
aria-label="Toggle icon"
duration={1.4}
from={<AppleIcon fontSize="2xl" />}
to={<CherryIcon fontSize="2xl" />}
/>
Delay
If you want to delay the switch, set a numerical value (seconds) to delay.
<Flip
aria-label="Toggle icon"
delay={1}
from={<AppleIcon fontSize="2xl" />}
to={<CherryIcon fontSize="2xl" />}
/>
Disable
To disable, set disabled to true.
<Flip
aria-label="Toggle icon"
disabled
from={<AppleIcon fontSize="2xl" />}
to={<CherryIcon fontSize="2xl" />}
/>
Read-Only
To ready-Only, set readOnly to true.
<Flip
aria-label="Toggle icon"
readOnly
from={<AppleIcon fontSize="2xl" />}
to={<CherryIcon fontSize="2xl" />}
/>
Control
const [value, onChange] = useState<KeyframeIdent>("from")
return (
<Flip
aria-label="Toggle icon"
from={<AppleIcon fontSize="2xl" />}
to={<CherryIcon fontSize="2xl" />}
value={value}
onChange={onChange}
/>
)
"use client" to the top of the file.Props
Accessibility
The Flip follows the WAI-ARIA - Button Pattern for accessibility.
When aria-label is set, it will be read aloud by screen readers.
<Flip
aria-label="Menu"
from={<MenuIcon fontSize="2xl" />}
to={<XIcon fontSize="2xl" />}
/>
Keyboard Navigation
| Key | Description | State |
|---|---|---|
Enter, Space | When element has focus, activates it. | - |