sdxc

[ @sdxc/u/transform ]

scaleY

Scales the element along the vertical axis only.

import { scaleY } from "@sdxc/u/transform";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.scaleY(1.5)css({ "--ui-scale-y": "1.5", transform: "... scale(var(--ui-scale-x, 1), var(--ui-scale-y, 1)) ..." })

Examples

Basic example

Use scaleY(n) with a unitless factor to resize an element vertically while its width stays the same:

scaleY(0.5)
scaleY(1)
scaleY(1.5)
<div mix={[...]}>
	<div mix={[...]}>
		<div mix={[scaleY(0.5), ...]}>scaleY(0.5)</div>
	</div>
	<div mix={[...]}>
		<div mix={[scaleY(1), ...]}>scaleY(1)</div>
	</div>
	<div mix={[...]}>
		<div mix={[scaleY(1.5), ...]}>scaleY(1.5)</div>
	</div>
</div>

Mirroring vertically

Use scaleY(-1) to flip an element upside down:

▾ menu
▾ menu
<div mix={[...]}>
	<div mix={[...]}>
		<div mix={[scaleY(1), ...]}>▾ menu</div>
	</div>
	<div mix={[...]}>
		<div mix={[scaleY(-1), ...]}>▾ menu</div>
	</div>
</div>

Flipping on open

Combine it with a state like open() to flip an indicator while a disclosure is open. Click the summary to try it:

Details ▾

The chevron flips while this panel is open.

<details mix={[open(when("& .chevron", scaleY(-1))), ...]}>
	<summary>
		Details{" "}
		<span class="chevron" mix={[inlineBlock(), transition("transform")]}>
			▾
		</span>
	</summary>
	<p>The chevron flips while this panel is open.</p>
</details>

Using a custom value

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

u.scaleY("2.75rem")

Applying on a state

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

u.hover(u.scaleY(1.5))

Responsive design

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

u.at("md", u.scaleY(1.5))

Signature

u.scaleY(value: ScaleValue)

Written by Sergio Xalambrí. Follow @sergiodxa for new packages, or sponsor the work.