[ @sdxc/u/transform ]
scale
Scales the element uniformly on both axes — sugar for setting u.scaleX() and u.scaleY() to the same factor in one call.
import { scale } from "@sdxc/u/transform";Quick reference
Every documented call, beside the CSS it emits.
| Call | CSS |
|---|---|
u.scale(1.5) | css({ "--ui-scale-x": "1.5", "--ui-scale-y": "1.5", transform: "..." }) |
Examples
Basic example
Use scale(n) with a unitless factor, like scale(0.75) or scale(1.25), to resize an element on both axes:
<div mix={[...]}>
<div mix={[...]}>
<div mix={[scale(0.75), ...]}>scale(0.75)</div>
</div>
<div mix={[...]}>
<div mix={[scale(1), ...]}>scale(1)</div>
</div>
<div mix={[...]}>
<div mix={[scale(1.25), ...]}>scale(1.25)</div>
</div>
</div>Using percentages
Pass a string to scale by a percentage, like scale("50%"):
<div mix={[...]}>
<div mix={[...]}>
<div mix={[scale("50%"), ...]}>scale("50%")</div>
</div>
<div mix={[...]}>
<div mix={[scale("110%"), ...]}>scale("110%")</div>
</div>
</div>Using negative values
A negative factor, like scale(-1), mirrors an element on both axes:
<div mix={[...]}>
<div mix={[...]}>
<div mix={[scale(-1), ...]}>scale(-1)</div>
</div>
<div mix={[...]}>
<div mix={[scale(-0.75), ...]}>scale(-0.75)</div>
</div>
</div>Applying on hover
Wrap it in hover() and add a transition("transform") to grow an element under the pointer. Hover the tile to try it:
<div mix={[...]}>
<div mix={[...]}>
<div mix={[hover(scale(1.15)), transition("transform"), ...]}>hover me</div>
</div>
</div>Using a custom value
Every scale argument also takes a raw CSS value, which passes through untouched.
u.scale("2.75rem")Applying on a state
Wrap the call in a state utility to scope it to one selector.
u.hover(u.scale(1.5))Responsive design
Wrap the call in a container query to scope it to one width.
u.at("md", u.scale(1.5))Signature
u.scale(value: ScaleValue)