Gradients
Four named gradients ship as classes. Each reads a --nc-gradient-* token, so a
theme override re-tints it.
Named gradients
Section titled “Named gradients”| Class | Shape |
|---|---|
gradient-primary_success |
145deg, primary → success |
gradient-primary-light-3_primary |
top → bottom, primary → light primary |
gradient-red_yellow_blue |
left → right, red → yellow → blue |
gradient-info_transparent |
90deg, info → transparent |
<div class="gradient-primary_success" style="min-height: 6rem"></div>Override one instance with --gradient, or redefine its token:
.hero { --nc-gradient-primary-success: linear-gradient(135deg, var(--nc-accent), var(--nc-info));}For anything else, build the gradient from tokens. Direction, stops, and dark-mode behaviour are design decisions worth seeing in your stylesheet.
A soft accent wash
Section titled “A soft accent wash”.hero { background: linear-gradient( 135deg, color-mix(in oklch, var(--nc-accent) 22%, var(--nc-surface)), var(--nc-surface) 62% );}The mix keeps the accent from overwhelming the page. Use a stronger mix for a promo panel, a weaker one for a page header.
A surface sheen
Section titled “A surface sheen”.panel { background: linear-gradient( to bottom, var(--nc-surface-raised), var(--nc-surface) );}This reads as a subtle material change rather than a “gradient”, and both stops are tokens, so it works in both themes.
Gradient text
Section titled “Gradient text”Set the text colour to transparent only when background-clip: text is
supported, and keep a solid fallback:
.gradient-text { color: var(--nc-accent);}
@supports (background-clip: text) or (-webkit-background-clip: text) { .gradient-text { background: linear-gradient( 90deg, var(--nc-accent), color-mix(in oklch, var(--nc-accent) 40%, var(--nc-text)) ); -webkit-background-clip: text; background-clip: text; color: transparent; }}Keep gradient text for short display lines. It lowers contrast and is hard to read at body sizes.
An image scrim
Section titled “An image scrim”<div class="relative overflow-hidden rounded-lg" style="aspect-ratio: 16 / 9"> <img src="…" alt="…" style="inline-size: 100%; block-size: 100%; object-fit: cover" /> <div class="absolute inset-0" style="background: linear-gradient(to top, rgb(0 0 0 / 0.72), transparent 62%)"></div> <p class="absolute" style="inset-block-end: 1rem; inset-inline: 1rem; color: white">Text over a scrim</p></div>The scrim is what makes white text legible. Do not put text directly on a busy photo and hope.
A radial glow
Section titled “A radial glow”.glow { background: radial-gradient( circle at 30% 20%, color-mix(in oklch, var(--nc-accent) 28%, transparent), transparent 58% ), var(--nc-surface);}A gradient border
Section titled “A gradient border”.gradient-border { border: 1px solid transparent; background: linear-gradient(var(--nc-surface), var(--nc-surface)) padding-box, linear-gradient(90deg, var(--nc-accent), transparent) border-box;}Theming
Section titled “Theming”Every example above reads --nc-accent, so overriding the accent re-themes it:
<div style="--nc-accent: oklch(62% 0.19 25)"> <div class="gradient-primary_success">…</div></div>See Theming for the full override model and Color for the tokens.
Accessibility
Section titled “Accessibility”- Do not put body text on a gradient without a solid scrim or a solid panel.
- Check contrast against the lightest and darkest stop, not the average.
- Keep gradient text to short lines.
- Gradients have no breakpoint variants. They are colour, not layout.
Use in CSS
Section titled “Use in CSS”The class is the markup shorthand. The same style in a component stylesheet:
.hero { background-image: var(--nc-gradient-primary-success);}The Sass subpackage exposes the same value: nc.nc-gradient("primary_success").
See Sass subpackage.
A breakpoint is the same declaration inside a media query; you do not need a second class.