Opacity
Opacity utilities set opacity. The scale is ordinal: 0 is fully transparent,
then the steps move in 10% increments starting at 5%.
Classes
Section titled “Classes”| Class | Opacity |
|---|---|
opacity-0 |
0% |
opacity-1 |
5% |
opacity-2 |
15% |
opacity-3 |
25% |
opacity-4 |
35% |
opacity-5 |
45% |
opacity-6 |
55% |
opacity-7 |
65% |
opacity-8 |
75% |
opacity-9 |
85% |
opacity-10 |
95% |
<div class="opacity-5">45% opacity</div><div class="opacity-5" style="--opacity: .4">40% opacity</div>Responsive opacity
Section titled “Responsive opacity”Responsive: opacity-sm-5, opacity-md-5, …, opacity-2xl-5.
These classes are in the separate responsive module: import
nightcss/utilities/responsive after the base bundle, or use
nightcss/full.
<div class="opacity-0 opacity-md-10">Fades in on wider screens</div>What opacity affects
Section titled “What opacity affects”Opacity fades the whole element, including its children. When only the colour should be transparent, mix the colour instead:
.meta { color: color-mix(in oklch, var(--nc-text) 60%, var(--nc-surface));}Do not use opacity to make secondary text quieter; it lowers contrast for
everything inside. Use text-muted.
Keep opacity for disabled states, entering elements, and decorative layers. For
the scale that rebuilds a surface, see Color.