Rotate
Rotate is a component that provides an animation to switch between two elements while rotating.
<Rotate
aria-label="Toggle icon"
from={<AppleIcon fontSize="2xl" />}
to={<CherryIcon fontSize="2xl" />}
/>
Usage
import { Rotate } from "@yamada-ui/react"
import { Rotate } from "@/components/ui"
import { Rotate } from "@workspaces/ui"
<Rotate />
Change Rotate
To change the rotate, set rotate to a numerical value. By default, 45 is set.
<Rotate
aria-label="Toggle icon"
rotate={-360}
from={<AppleIcon fontSize="2xl" />}
to={<CherryIcon fontSize="2xl" />}
/>
Change Duration
To change the duration, set a numerical value (seconds) to duration.
<Rotate
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.
<Rotate
aria-label="Toggle icon"
delay={1}
from={<AppleIcon fontSize="2xl" />}
to={<CherryIcon fontSize="2xl" />}
/>
Disable
To disable, set disabled to true.
<Rotate
aria-label="Toggle icon"
disabled
from={<AppleIcon fontSize="2xl" />}
to={<CherryIcon fontSize="2xl" />}
/>
Read-Only
To ready-Only, set readOnly to true.
<Rotate
aria-label="Toggle icon"
readOnly
from={<AppleIcon fontSize="2xl" />}
to={<CherryIcon fontSize="2xl" />}
/>
Control
const [value, onChange] = useState<KeyframeIdent>("from")
return (
<Rotate
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 Rotate follows the WAI-ARIA - Button Pattern for accessibility.
When aria-label is set, it will be read aloud by screen readers.
<Rotate
aria-label="Menu"
from={<MenuIcon fontSize="2xl" />}
to={<XIcon fontSize="2xl" />}
/>
Keyboard Navigation
| Key | Description | State |
|---|---|---|
Enter, Space | When element has focus, activates it. | - |