[ @sdxc/u/size ]
min-width
Applies the physical min-width property, for elements whose sizing is tied to the physical viewport axis.
import { minWidth } from "@sdxc/u/size";Quick reference
Every documented call, beside the CSS it emits.
| Call | CSS |
|---|---|
u.minWidth("full") | css({ minWidth: "100%" }) |
Examples
Basic example
Use minWidth(n) to give an element a minimum width, like buttons that stay at least minWidth(32) wide however short their label:
<div mix={[...]}>
<button type="button" mix={[minWidth(32), ...]}>
OK
</button>
<button type="button" mix={[minWidth(32), ...]}>
Cancel
</button>
<button type="button" mix={[minWidth(32), ...]}>
Save and continue
</button>
</div>Truncating inside flex
A flex item will not shrink below its content by default, so text truncated inside it overflows instead; use minWidth(0) on the item to let it shrink:
quarterly-report-final-version-with-every-appendix.pdf
quarterly-report-final-version-with-every-appendix.pdf
<div mix={[...]}>
<div mix={[hstack({ gap: 3 }), is(72), ...]}>
<div mix={[circle(), is(10), shrink(), ...]}>PDF</div>
<div>
<p mix={[truncate(), ...]}>
quarterly-report-final-version-with-every-appendix.pdf
</p>
</div>
</div>
<div mix={[hstack({ gap: 3 }), is(72), ...]}>
<div mix={[circle(), is(10), shrink(), ...]}>PDF</div>
<div mix={[minWidth(0)]}>
<p mix={[truncate(), ...]}>
quarterly-report-final-version-with-every-appendix.pdf
</p>
</div>
</div>
</div>Applying on a state
Wrap the call in a state utility to scope it to one selector.
u.hover(u.minWidth("full"))Responsive design
Wrap the call in a container query to scope it to one width.
u.at("md", u.minWidth("full"))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:
minWidth(4)Signature
u.minWidth(value: SizeValue)