[ @sdxc/u/size ]
margin-left
Sets the physical margin-left property directly, pinned to the fixed left edge regardless of writing direction.
import { marginLeft } from "@sdxc/u/size";Quick reference
Every documented call, beside the CSS it emits.
| Call | CSS |
|---|---|
u.marginLeft(4) | css({ marginLeft: "calc(var(--ui-spacing, 0.25rem) * 4)" }) |
Examples
Basic example
Use marginLeft(n) to add margin to the left edge of an element, whatever the writing direction:
<div mix={[...]}>
<div mix={[marginLeft(12), ...]}>marginLeft(12)</div>
</div>Right-to-left text
In right-to-left text marginLeft() stays on the left, while mis() follows the direction to the start of the line on the right:
<div dir="rtl" mix={[...]}>
<div mix={[...]}>
<div mix={[marginLeft(12), ...]}>marginLeft(12)</div>
</div>
<div mix={[...]}>
<div mix={[mis(12), ...]}>mis(12)</div>
</div>
</div>Using a custom value
Every scale argument also takes a raw CSS value, which passes through untouched.
u.marginLeft("2.75rem")Applying on a state
Wrap the call in a state utility to scope it to one selector.
u.hover(u.marginLeft(4))Responsive design
Wrap the call in a container query to scope it to one width.
u.at("md", u.marginLeft(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:
marginLeft(4)Signature
u.marginLeft(value: SpacingValue)