Skip to content

Gradients

Four named gradients ship as classes. Each reads a --nc-gradient-* token, so a theme override re-tints it.

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.

.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.

.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.

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;
}
}
Gradient text

Keep gradient text for short display lines. It lowers contrast and is hard to read at body sizes.

<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.

.glow {
background:
radial-gradient(
circle at 30% 20%,
color-mix(in oklch, var(--nc-accent) 28%, transparent),
transparent 58%
),
var(--nc-surface);
}
.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;
}

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.

  • 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.

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.