sdxc

[ @sdxc/u/layout ]

left

Applies the physical left property, for offsets genuinely tied to the viewport's left side.

import { insLeft } from "@sdxc/u/layout";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.insLeft(4)css({ left: "calc(var(--ui-spacing, 0.25rem) * 4)" })

Examples

Basic example

Use insLeft(n) to set the left offset of a positioned element from the spacing scale:

insLeft(0)
insLeft(6)
<div mix={[...]}>
	<div mix={[relative(), is(48), bs(32), ...]}>
		<div mix={[absolute(), insLeft(0), ...]}>insLeft(0)</div>
	</div>
	<div mix={[relative(), is(48), bs(32), ...]}>
		<div mix={[absolute(), insLeft(6), ...]}>insLeft(6)</div>
	</div>
</div>

Placing beside the parent

Use insLeft("full") to start an element where its positioned parent ends, like a note beside the box it describes:

Draft
← saved 2 minutes ago
<div mix={[relative(), ...]}>
	Draft
	<div mix={[absolute(), insLeft("full"), insTop(0), mis(3), nowrap(), ...]}>
		← saved 2 minutes ago
	</div>
</div>

Using a custom value

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

u.insLeft("2.75rem")

Applying on a state

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

u.hover(u.insLeft(4))

Responsive design

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

u.at("md", u.insLeft(4))

Customizing your theme

Customizing spacing

Every numeric step multiplies --ui-spacing, so redefining it rescales every spacing and sizing utility at once:

:root {
	--ui-spacing: 0.25rem;
}

Every call that names the step now reads the new value:

insLeft(4)

Signature

u.insLeft(value: SizeValue)

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