sdxc

[ @sdxc/u/size ]

margin-right

Sets the physical margin-right property directly, pinned to the fixed right edge regardless of writing direction.

import { marginRight } from "@sdxc/u/size";

Quick reference

Every documented call, beside the CSS it emits.

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

Examples

Basic example

Use marginRight(n) to add margin to the right edge of an element, whatever the writing direction:

marginRight(12)
<div mix={[...]}>
	<div mix={[marginRight(12), ...]}>marginRight(12)</div>
</div>

Right-to-left text

In right-to-left text marginRight() stays on the right, while mie() follows the direction to the end of the line on the left:

marginRight(12)
mie(12)
<div dir="rtl" mix={[...]}>
	<div mix={[...]}>
		<div mix={[marginRight(12), ...]}>marginRight(12)</div>
	</div>
	<div mix={[...]}>
		<div mix={[mie(12), ...]}>mie(12)</div>
	</div>
</div>

Using a custom value

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

u.marginRight("2.75rem")

Applying on a state

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

u.hover(u.marginRight(4))

Responsive design

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

u.at("md", u.marginRight(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:

marginRight(4)

Signature

u.marginRight(value: SpacingValue)

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