Sizing
Set width and height with the spacing scale, arbitrary Length values or the predefined Size keywords.
Width and height
The numeric width and height helpers use the same scale as spacing. There are also a few named keywords for common cases.
| Utility | Generated CSS |
|---|---|
W(4) |
width: 1rem |
H(4) |
height: 1rem |
WFull() |
width: 100% |
WScreen() |
width: 100vw |
WAuto() |
width: auto |
HFull() |
height: 100% |
HScreen() |
height: 100vh |
<div class="@Css.W(32).H(8)"></div>
<div class="@Css.WFull().H(8)"></div>
<div class="@Css.W(16).HFull()"></div>
Minimum and maximum
Min and max helpers take either a predefined Size
value or any Length. Use
Size for the named keywords and
Length for arbitrary values, other units and reusable
project tokens.
| Utility | Generated CSS |
|---|---|
MaxW(Size.Md) |
max-width: 48rem |
MinW(Size.Sm) |
min-width: 40rem |
MaxH(Size.Lg) |
max-height: 64rem |
MinH(Size.ScreenH) |
min-height: 100vh |
MaxW(Length.Px(720)) |
max-width: 720px |
MinH(Length.Vh(100)) |
min-height: 100vh |
Available sizes
| Utility | Generated CSS |
|---|---|
Size.Sm |
40rem |
Size.Md |
48rem |
Size.Lg |
64rem |
Size.Xl |
80rem |
Size.Xxl |
96rem |
Size.Xxxl |
128rem |
Size.Full |
100% |
Size.ScreenW |
100vw |
Size.ScreenH |
100vh |
Size.Zero |
0px |
Size.Min |
min-content |
Size.Max |
max-content |
Size.Fit |
fit-content |
Arbitrary sizes with Length
A Length works everywhere a
Size does, and covers units the named set does not
include.
// Any Length works with MaxW / MinW / MaxH / MinH:
Css.MaxW(Length.Px(720)); // max-w-720px
Css.MinW(Length.Percent(50)); // min-w-50%
Css.MinH(Length.Vh(100)); // min-h-100vh
Css.MaxH(new Length("min-content", "min")); // max-h-min
// Or a reusable token:
public static readonly Length Reading = new("65ch", "reading");
Css.MaxW(Reading); // max-w-reading
min-height: 12rem, max-width: 65ch
<div class="@(Css.MinH(HeroHeight).MaxW(ReadingWidth).P(6))">
min-height: 12rem, max-width: 65ch
</div>
max-width: 48rem
<div class="@Css.MaxW(Size.Md).P(6)">
max-width: 48rem
</div>