Skip to content

Sass Subpackage

The optional nightcss/scss subpackage mirrors the CSS tokens as Sass maps and exposes accessor functions and mixins — all on the modern module system (@use/@forward, sass:map), with no @import and no !important.

@use "nightcss/scss" as nc;

The accessors read the same scales that back the utility classes: nc-space(4) and p-4 both resolve to --nc-space-4. That means one value can be a class in markup or a property in a component stylesheet. Plain CSS can skip the subpackage and read the token directly: padding: var(--nc-space-4). See Utilities for the side-by-side examples.

The token maps are re-exported for compile-time access and math. Every map is marked !default, so a project can override values before @use:

@use "nightcss/scss" with (
$nc-space: (
4: 1.25rem,
),
);
Map Keys
$nc-breakpoints sm, md, lg, xl, 2xl
$nc-space 0 … 24 (4px steps)
$nc-font sans, mono, base, headings, displays
$nc-text xs, sm, base, lg, xl, 2xl, 3xl, 4xl
$nc-leading none, tight, snug, normal, relaxed, loose
$nc-line-height 1, 25, 50, 75, 2
$nc-tracking tighter, tight, normal, wide, wider, widest
$nc-weight normal, medium, semibold, bold
$nc-radius none, sm, md, lg, xl, full, zero, small, base, large, circle
$nc-shadow xs, sm, md, lg, level-1 … level-5
$nc-duration fast, base, slow
$nc-ease standard, emphasized
$nc-speed shortest, shorter, short, base, slow, slower, lazy
$nc-timing linear, ease, standard, sharp, … (ten curves)
$nc-opacity 0 … 10 (ordinal opacity map)
$nc-palette Named palette and theme aliases
$nc-gradient primary_success, primary-light-3_primary, red_yellow_blue, info_transparent
$nc-z base, dropdown, sticky, overlay, modal, toast
$nc-color accent, accent-contrast, surface, surface-raised, text, text-muted, border, ring

Accessors emit var(--nc-*, <fallback>): the fallback keeps the output valid on its own, while the custom property keeps it themeable at runtime.

.card {
padding: nc.nc-space(4);
margin: nc.nc-space(4, 8); // two values, space-separated
font-size: nc.nc-text("lg");
line-height: nc.nc-leading("relaxed");
font-weight: nc.nc-weight("semibold");
border-radius: nc.nc-radius("md");
box-shadow: nc.nc-shadow("sm");
z-index: nc.nc-z("dropdown");
transition: nc.nc-transition(transform, base, emphasized);
}
Function Returns
nc.nc-space($keys...) One to four space values
nc.nc-text($key) Fluid type-scale value
nc.nc-leading($key) Line height
nc.nc-line-height($key) Line-height step (1, 25, 50, 75, 2)
nc.nc-tracking($key) Letter spacing
nc.nc-weight($key) Font weight
nc.nc-font($key) Font-family stack
nc.nc-radius($key) Border radius
nc.nc-shadow($key) Box shadow
nc.nc-z($key) Z-index
nc.nc-duration($key) Duration
nc.nc-ease($key) Easing
nc.nc-speed($key) Duration ladder
nc.nc-timing($key) Easing ladder
nc.nc-transition($property, $duration, $ease, $delay) Full semantic transition
nc.nc-motion($property, $speed, $timing, $delay) Full transition from the speed/timing ladders
nc.nc-opacity($key) Opacity percentage
nc.nc-palette($key) Named palette colour
nc.nc-gradient($key) Named gradient
nc.nc-color($key) Semantic color token
nc.nc-breakpoint($key) Literal breakpoint value

Colors mix in oklch at runtime with color-mix(). The helpers cover tinting, shading, and the named light/dark ladder:

.button {
background: nc.nc-color("accent");
color: nc.nc-color("accent-contrast");
border-color: nc.nc-tint(nc.nc-color("accent"), 80%);
}
.button:hover {
background: nc.nc-shade(nc.nc-color("accent"), 12%);
}
Function Returns
nc.nc-mix($a, $b, $weight) color-mix(in oklch, a w, b)
nc.nc-tint($color, $weight) Color mixed toward white
nc.nc-shade($color, $weight) Color mixed toward black
nc.nc-shade-level($color, $mode, $level) Named light/dark shade, level 1…5
.badge {
background: nc.nc-palette("primary");
color: nc.nc-shade-level(nc.nc-palette("primary"), "light", 4);
border-color: nc.nc-shade-level(nc.nc-palette("primary"), "dark", 2);
}

The flex-grid mixins (container/row/col/offset/order) are not provided. The classes .row / .col-* are available in the CSS bundle; native CSS Grid via the layout primitives is the recommended path for new code. What remains are small, framework-agnostic helpers.

@include nc.nc-media-up("md") {
.grid {
grid-template-columns: repeat(2, 1fr);
}
}
@include nc.nc-media-between("sm", "lg") {
/* tablet range */
}
Mixin Description
nc.nc-media-up($bp) @media (min-width: …)
nc.nc-media-down($bp) @media (max-width: …)
nc.nc-media-between($min, $max) @media (min) and (max)
@include nc.font-face("Roboto", "roboto-regular", 400, normal, "../fonts/roboto/");

font-face emits a self-hosted @font-face with font-display: swap and a woff2 + woff stack.

.icon {
@include nc.icon-size(24px);
}

icon-size($width, $height) fixes an element (typically an SVG icon) to exact dimensions, immune to flex compression.

.name {
@include nc.text-truncate(240px);
}

text-truncate($max-width) truncates a single line with an ellipsis.