Rotate
Also called CSS rotation
A CSS transform that turns an element around its transform origin by an angle, such as rotate(45deg).
import type { ComponentProps } from 'react';
import { Collapsible } from '@base-ui/react/collapsible';
export function ShippingDetails() {
return (
<Collapsible.Root className='w-80 rounded-xl border'>
<Collapsible.Trigger className='group flex w-full items-center justify-between px-4 py-3 text-sm font-medium'>
Shipping and returns
{/* Turn half a circle when the panel opens, around the icon's center. */}
<ChevronDownIcon className='size-4 transition-transform duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] group-data-panel-open:rotate-180 motion-reduce:transition-none' />
</Collapsible.Trigger>
<Collapsible.Panel className='px-4 pb-4 text-sm text-muted-foreground'>
Orders over $50 ship free. Return anything within 30 days for a full
refund.
</Collapsible.Panel>
</Collapsible.Root>
);
}
function ChevronDownIcon(props: ComponentProps<'svg'>) {
return (
<svg
viewBox='0 0 16 16'
fill='none'
stroke='currentColor'
strokeWidth={1.5}
aria-hidden='true'
{...props}
>
<path d='m4 6 4 4 4-4' />
</svg>
);
}Rotate the accordion chevron 180deg when its panel opens and back to 0 when it closes, using a 200ms transform transition with cubic-bezier(0.23, 1, 0.32, 1). Keep the rotation centered on the icon, and turn off the transition when prefers-reduced-motion is set.
Paste into Layerwise or any AI coding tool.
What is Rotate?
transform: rotate(45deg) turns an element clockwise; negative angles turn it counterclockwise. CSS accepts deg, turn, and rad, so rotate(0.5turn) is the same as rotate(180deg). The element spins around its transform origin, the center by default, and plain rotate stays flat on the screen. rotateX and rotateY tilt it in 3D instead.
Common uses: a chevron that turns 180deg when an accordion opens, a plus icon that becomes a close icon at 45deg, a loading spinner that loops from 0 to 360deg, or a playful 2 to 3deg tilt on hover.
CSS animates the number itself, so going from 350deg to 10deg spins backward through 340 degrees. Animate to 370deg instead if you want the short way round. Use linear timing for spinners that loop forever, and slow or stop them for people who prefer reduced motion.
Related terms
All termsTransform origin
The point an element rotates and scales around. It defaults to the center, and moving it changes where a transform seems to start.
Spinner
A small looping animation, usually a rotating ring, that shows the app is busy with a short task of unknown length.
3D flip
A card that turns over in 3D to reveal a second face on its back, built with `rotateY` and `backface-visibility: hidden`.
Accordion
A vertical stack of headings that each expand to reveal their content when clicked, so long pages stay short and easy to scan.
Build it with Layerwise
Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.