# max-width

> Applies the physical `max-width` property, for elements whose sizing is genuinely tied to the physical viewport axis.

```ts
import { maxWidth } from "@sdxc/u/size";
```

Applies the physical `max-width` property, for elements whose sizing is
genuinely tied to the physical viewport axis. Prefer `u.maxIs()`
(`max-inline-size`) for the logical default.

## Quick reference

Every documented call, beside the CSS it emits.

| Call | CSS |
| --- | --- |
| `u.maxWidth("full")` | `css({ maxWidth: "100%" })` |

## Examples

### Basic example

Use `maxWidth(n)` to cap an element's physical width, like `maxWidth(64)` or `maxWidth(96)`:

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

### Readable line length

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

```tsx
<p mix={[maxWidth("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.

```ts
u.hover(u.maxWidth("full"))
```

## Responsive design

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

```ts
u.at("md", u.maxWidth("full"))
```

## Customizing your theme

### Customizing spacing

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

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

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

```ts
maxWidth(4)
```

## Signature

```ts
u.maxWidth(value: SizeValue)
```
