SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

rotate

Rotates the element in its own 2D plane.

tsx
import { rotate } from "@sdxc/u/transform";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.rotate(45)css({ "--ui-rotate": "45deg", transform: "... rotate(var(--ui-rotate, 0deg)) ..." })

Examples

Basic example

Use rotate(n) with a number of degrees, like rotate(45) or rotate(90), to turn an element in its own plane:

rotate(45)
rotate(90)
rotate(210)
tsx
<div mix={[...]}>
	<div mix={[...]}>
		<div mix={[rotate(45), ...]}>rotate(45)</div>
	</div>
	<div mix={[...]}>
		<div mix={[rotate(90), ...]}>rotate(90)</div>
	</div>
	<div mix={[...]}>
		<div mix={[rotate(210), ...]}>rotate(210)</div>
	</div>
</div>

Using negative values

Pass a negative number, like rotate(-15), to turn an element counterclockwise:

rotate(-15)
rotate(-45)
rotate(15)
tsx
<div mix={[...]}>
	<div mix={[...]}>
		<div mix={[rotate(-15), ...]}>rotate(-15)</div>
	</div>
	<div mix={[...]}>
		<div mix={[rotate(-45), ...]}>rotate(-45)</div>
	</div>
	<div mix={[...]}>
		<div mix={[rotate(15), ...]}>rotate(15)</div>
	</div>
</div>

Using other angle units

Pass a string to use any CSS angle unit, like rotate("0.125turn") or rotate("1rad"):

rotate("0.125turn")
rotate("1rad")
rotate("50grad")
tsx
<div mix={[...]}>
	<div mix={[...]}>
		<div mix={[rotate("0.125turn"), ...]}>rotate("0.125turn")</div>
	</div>
	<div mix={[...]}>
		<div mix={[rotate("1rad"), ...]}>rotate("1rad")</div>
	</div>
	<div mix={[...]}>
		<div mix={[rotate("50grad"), ...]}>rotate("50grad")</div>
	</div>
</div>

Applying on hover

Wrap it in hover() and add a transition("transform") to turn an element when the pointer is over it. Hover the tile to try it:

hover me
tsx
<div mix={[...]}>
	<div mix={[...]}>
		<div mix={[hover(rotate(12)), transition("transform"), ...]}>hover me</div>
	</div>
</div>

Using a custom value

Every scale argument also takes a raw CSS value, which passes through untouched.

typescript
u.rotate("2.75rem")

Applying on a state

Wrap the call in a state utility to scope it to one selector.

typescript
u.hover(u.rotate(45))

Responsive design

Wrap the call in a container query to scope it to one width.

typescript
u.at("md", u.rotate(45))

Signature

typescript
u.rotate(value: AngleValue)
@sdxc/u

Can’t find it? Contact us