[ @sdxc/u/size ]
margin-inline
Applies margin-inline.
import { mi } from "@sdxc/u/size";Quick reference
Every documented call, beside the CSS it emits.
| Call | CSS |
|---|---|
u.mi(4, "auto") | css({ marginInline: "calc(var(--ui-spacing, 0.25rem) * 4) auto" }) |
Examples
Basic example
Use mi(n) to add margin to the inline-start and inline-end edges of an element, left and right of it in horizontal text:
mi(8)
<div mix={[...]}>
<div mix={[mi(8), ...]}>mi(8)</div>
</div>Start and end
Pass two values to set the inline-start and then the inline-end margin, like mi(2, 12):
mi(2, 12)
<div mix={[...]}>
<div mix={[mi(2, 12), ...]}>mi(2, 12)</div>
</div>Centering with auto
Use mi("auto") to center an element that has a width inside its container:
mi("auto")
<div mix={[...]}>
<div mix={[mi("auto"), is(64), ...]}>mi("auto")</div>
</div>Applying on a state
Wrap the call in a state utility to scope it to one selector.
u.hover(u.mi(4, "auto"))Responsive design
Wrap the call in a container query to scope it to one width.
u.at("md", u.mi(4, "auto"))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:
mi(4)Signature
u.mi(...values: SpacingValue[])