sdxc

[ @sdxc/u/size ]

max-inline-size

Applies max-inline-size.

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

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.maxIs("60ch")css({ maxInlineSize: "60ch" })
u.maxIs("full")css({ maxInlineSize: "100%" })

Examples

Basic example

Use maxIs(n) to cap an element's inline size, like maxIs(64) or maxIs(96):

maxIs(128)
maxIs(96)
maxIs(64)
maxIs(48)
<div mix={[...]}>
	<div mix={[maxIs(128), ...]}>maxIs(128)</div>
	<div mix={[maxIs(96), ...]}>maxIs(96)</div>
	<div mix={[maxIs(64), ...]}>maxIs(64)</div>
	<div mix={[maxIs(48), ...]}>maxIs(48)</div>
</div>

Readable line length

Pass any CSS length as a string, like maxIs("45ch"), to keep lines of text at a comfortable length:

Margins, padding and sizes in this package follow the writing mode, so a layout written once reads correctly in every language. A card padded on its inline start keeps that padding where a sentence begins, whichever side of the screen that is, and the same holds for a list, a sidebar or a toolbar.

<p mix={[maxIs("45ch"), ...]}>
	Margins, padding and sizes in this package follow the writing mode, so a layout written once
	reads correctly in every language. A card padded on its inline start keeps that padding where
	a sentence begins, whichever side of the screen that is, and the same holds for a list, a
	sidebar or a toolbar.
</p>

Applying on a state

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

u.hover(u.maxIs("60ch"))

Responsive design

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

u.at("md", u.maxIs("60ch"))

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:

maxIs(4)

Signature

u.maxIs(value: SizeValue)

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