Padding
Padding utilities run 0 through 24 on the same 4px scale as the
--nc-space-* tokens. --nc-space-4 is 1rem, so p-4 is one rem of padding
in every direction.
Classes
Section titled “Classes”| Class pattern | Property |
|---|---|
p-0 … p-24 |
padding |
px-* |
padding-inline |
py-* |
padding-block |
pt-* |
padding-top |
pr-* |
padding-right |
pb-* |
padding-bottom |
pl-* |
padding-left |
<div class="p-4">One rem all around</div><div class="px-6 py-3">Wider than it is tall</div><div class="pt-0 pb-8">No top padding, two rems at the bottom</div>The family reads --p, so a one-off value does not need a new class:
<div class="p-4" style="--p: 37px">One-off padding</div>Responsive padding
Section titled “Responsive padding”These classes are in the separate responsive module: import
nightcss/utilities/responsive after the base bundle, or use
nightcss/full.
The shorthand families accept breakpoint suffixes:
<div class="p-2 p-md-4 p-lg-6">Grows with the viewport</div>Responsive forms exist for p-*, px-*, and py-*. Individual sides (pt-*,
pr-*, pb-*, pl-*) are base-only to keep the bundle small; write a media
query for the rare responsive side.
For outer spacing, see Margin. For space between children, see Gap.
Use in CSS
Section titled “Use in CSS”The class is the markup shorthand. The same style in a component stylesheet:
.article { padding: var(--nc-space-4);}.article-wide { padding-inline: var(--nc-space-6);}The Sass subpackage exposes the same values: nc.nc-space(4) and
nc.nc-space(6). See Sass subpackage.
A breakpoint is the same declaration inside a media query; you do not need a second class.