ramps.ts

The derived color system's ramp model and fitted default knob values.

This is the numeric single source of truth for the OKLCH palette: the same constants and formulas that variables.ts renders as pure-CSS calc()/pow()/oklch() defaults, evaluated here in TypeScript so design-time tests and the theme gates (theme_check.ts) can reason about the palette without a browser.

The knob values were fitted against the pre-OKLCH HSL palette to minimize the perceptual delta of the port. Model shapes:

  • lightness: L(t) = L00 + (L100 - L00) * pow(t, curve) with t = stop/100
    • the endpoint knobs literally are stops 00/100, so the dark scheme flips

    direction purely through knob values

  • chroma: C(t) = min + (max - min) * pow(4t(1-t), curve), a symmetric mid-peaked curve, clamped per stop by the worst-hue gamut caps below
  • the neutral scale rides the same chroma shape scaled by a single knob
view source

Declarations
#

69 declarations

BORDER_CHROMA_MULTIPLIER
#

ramps.ts view source

Readonly<Record<"light" | "dark", number>>

type Readonly<Record<ColorScheme, number>>

import {BORDER_CHROMA_MULTIPLIER} from '@fuzdev/fuz_css/ramps.js';

The border family's chroma as a multiple of --neutral_chroma - borders carry a stronger tint than surfaces so they read at low alpha. In CSS this is --border_color_chroma: calc(var(--neutral_chroma) * <multiple>).

BORDER_COLOR_ALPHAS
#

ramps.ts view source

Readonly<Record<"light" | "dark", Readonly<Record<"00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100", number>>>>

type Readonly<Record<ColorScheme, Readonly<Record<NumericScaleVariant, number>>>>

import {BORDER_COLOR_ALPHAS} from '@fuzdev/fuz_css/ramps.js';

Alpha (in %) of each border color stop. A perceptually-uniform curve - small gaps at the low end, large at the high end - boosted at the low end in dark mode where borders are less visible against dark backgrounds. Stop 00 renders transparent and stop 100 opaque.

BORDER_COLOR_LIGHTNESS
#

ramps.ts view source

Readonly<Record<"light" | "dark", number>>

type Readonly<Record<ColorScheme, number>>

import {BORDER_COLOR_LIGHTNESS} from '@fuzdev/fuz_css/ramps.js';

OKLCH lightness of the border color family (--border_color_lightness), fitted from the HSL palette. Sits mid-ramp so borders read against both the page background and fills.

border_color_oklch
#

ramps.ts view source

(scheme: "light" | "dark"): Oklch import {border_color_oklch} from '@fuzdev/fuz_css/ramps.js';

Computes the default OKLCH color of the border family (without alpha).

scheme

returns

Oklch

BORDER_CONTRAST_GAIN
#

ramps.ts view source

number import {BORDER_CONTRAST_GAIN} from '@fuzdev/fuz_css/ramps.js';

How fast the default control border moves the rest of the way to its reach stop: the share of reach in the mix is min(1, BORDER_CONTRAST_REST_SHARE + BORDER_CONTRAST_GAIN * c) at effective contrast c. The gain is derived so the share reaches 1 at HIGH_CONTRAST exactly: the high-contrast border is the reach stop itself, which every shipped theme that keeps the default border clears 3:1 against the ground with margin to spare, and a control on the first raised surface (shade_10) clears it too, in both schemes.

BORDER_CONTRAST_REST_SHARE
#

ramps.ts view source

0.25 import {BORDER_CONTRAST_REST_SHARE} from '@fuzdev/fuz_css/ramps.js';

The share of the reach stop in the default control border at no contrast. The shade curve holds rest close to the ground so raised surfaces stay calm, which alone leaves control borders a shade too soft; this fixed share of reach puts them back at about 2:1 against the ground at rest, still well under the 3:1 that contrast brings.

border_contrast_share
#

ramps.ts view source

(contrast: number): number import {border_contrast_share} from '@fuzdev/fuz_css/ramps.js';

The share of the reach stop in the default control border at an effective contrast, from 0 to 1. The numeric twin of the percentage in render_border_color_css.

contrast

the effective contrast (effective_contrast)

type number

returns

number

BORDER_CONTRAST_STOPS
#

ramps.ts view source

Readonly<{ rest: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100"; reach: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100"; }>

type Readonly<{ rest: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100"; reach: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100"; }>

import {BORDER_CONTRAST_STOPS} from '@fuzdev/fuz_css/ramps.js';

The shade stops the default control border (--border_color) mixes between: near rest at no contrast (BORDER_CONTRAST_REST_SHARE of the way toward reach), moving to reach as the effective contrast rises (BORDER_CONTRAST_GAIN). The shade bend stays small so the surfaces hold near the ground under contrast, which leaves the border to strengthen on its own - toward WCAG 1.4.11's 3:1 against the ground at HIGH_CONTRAST, while borders at no contrast stay deliberately softer.

CHROMA_STOP_CSS_MATCHER
#

ramps.ts view source

internal

Shared by `variable.ts` and `theme_resolver.ts` - not stable API.

RegExp import {CHROMA_STOP_CSS_MATCHER} from '@fuzdev/fuz_css/ramps.js';

Matches the capped form render_chroma_stop_css emits, capturing the stop and the cap - how the resolver reads a compiled cap back, and how the Theme schema admits the one intermediate a theme can carry (see StyleVariable). It admits CSS whitespace only, around the value and inside it, so a match needs no trim() (which, like \s, takes U+00A0).

ChromaRampKnobs
#

ramps.ts view source

ChromaRampKnobs import type {ChromaRampKnobs} from '@fuzdev/fuz_css/ramps.js';

Knobs for the symmetric mid-peaked chroma curve, C(t) = min + (max - min) * pow(4t(1-t), curve). The curve expresses the *request*; rendered stops are clamped by PALETTE_CHROMA_CAPS per stop, and --chroma_scale multiplies above the clamp (so vivid themes can knowingly push past the caps and gamut-clip).

chroma_min

Chroma requested at the ramp endpoints (stops 00/100), before capping.

type number

chroma_max

Chroma requested at the ramp midpoint (stop 50), before capping.

type number

curve

Falloff exponent of the peak; higher concentrates chroma at the middle.

type number

compute_worst_hue_chroma_cap
#

ramps.ts view source

(hues: readonly number[], lightness: number): number import {compute_worst_hue_chroma_cap} from '@fuzdev/fuz_css/ramps.js';

Computes the worst-hue safe chroma cap at one lightness: the minimum oklch_max_srgb_chroma across the hues, floored to 4 decimals to stay conservative (the browser clips anything past it). The generalization of the baked PALETTE_CHROMA_CAPS to an arbitrary hue set and lightness - a theme's compile step calls it with each stop's own resolved lightness to detect where the baked worst-hue envelope no longer fits.

hues

OKLCH hue angles the stop must stay in gamut for

type readonly number[]

lightness

the stop's OKLCH lightness

type number

returns

number

CONTRAST
#

ramps.ts view source

0 import {CONTRAST} from '@fuzdev/fuz_css/ramps.js';

The default of the --contrast knob: the theme's own ramps, unmoved.

CONTRAST_CURVE_BEND
#

ramps.ts view source

Readonly<Record<"text" | "shade", number>>

type Readonly<Record<"text" | "shade", number>>

import {CONTRAST_CURVE_BEND} from '@fuzdev/fuz_css/ramps.js';

How far full contrast bends each neutral lightness curve: the effective curve is curve * (1 - CONTRAST_CURVE_BEND[family] * c). The text bend pulls the text stops toward the contrast end. The shade bend is the smaller one, so the near-ground surfaces keep close to the stretched ground rather than moving toward the text on them - which would lower body text on shade_10 as contrast rises. The control border strengthens on its own instead (BORDER_CONTRAST_STOPS).

contrast_ground_end
#

ramps.ts view source

(scheme: "light" | "dark", lightness_00: number): number import {contrast_ground_end} from '@fuzdev/fuz_css/ramps.js';

The ground end a scheme stretches toward, clamped to the ground: the larger of CONTRAST_GROUND_END.light and the ground in light, the smaller of CONTRAST_GROUND_END.dark and the ground in dark, so a ground already past the end stays put. The numeric twin of render_contrast_ground_end_css.

scheme

the scheme whose end applies - a stanced theme's stance

lightness_00

the ground's lightness (shade_lightness_00)

type number

returns

number

CONTRAST_GROUND_END
#

ramps.ts view source

Readonly<Record<"light" | "dark", number>>

type Readonly<Record<ColorScheme, number>>

import {CONTRAST_GROUND_END} from '@fuzdev/fuz_css/ramps.js';

The ground lightness full contrast reaches, per scheme: the effective ground (--_shade_lightness_00) moves the fraction c of the way from the theme's own --shade_lightness_00 to this end. The dark end stops short of black, since the bottom of the lightness range carries almost no luminance. The end is clamped to the ground (contrast_ground_end), so the stretch only moves toward the scheme's extreme: a ground already past the end doesn't move, though the shade and text curves still bend.

CONTRAST_GROUND_END_NAME
#

ramps.ts view source

"_contrast_ground_end" import {CONTRAST_GROUND_END_NAME} from '@fuzdev/fuz_css/ramps.js';

The private two-slot variable holding the ground's contrast end, clamped to the ground (contrast_ground_end).

contrast_ground_lightness
#

ramps.ts view source

(lightness_00: number, end: number, contrast: number): number import {contrast_ground_lightness} from '@fuzdev/fuz_css/ramps.js';

The effective ground lightness: lightness_00 moved the fraction contrast of the way to end. The numeric twin of render_contrast_ground_lightness_css.

lightness_00

type number

end

type number

contrast

type number

returns

number

contrast_lightness_curve
#

ramps.ts view source

(family: "text" | "shade", curve: number, contrast: number): number import {contrast_lightness_curve} from '@fuzdev/fuz_css/ramps.js';

The effective shade or text curve: curve bent by the family's CONTRAST_CURVE_BEND at contrast. The numeric twin of render_contrast_curve_css.

family

the neutral ramp, which picks the bend

type "text" | "shade"

curve

the ramp's curve knob

type number

contrast

the effective contrast (effective_contrast)

type number

returns

number

contrast_lightness_knobs
#

ramps.ts view source

(family: RampFamily, knobs: LightnessRampKnobs, contrast: number, scheme: "light" | "dark"): LightnessRampKnobs import {contrast_lightness_knobs} from '@fuzdev/fuz_css/ramps.js';

The lightness knobs a ramp renders at an effective contrast c: the shade ground moves the fraction c of the way to its end (contrast_ground_end, which never lies behind the ground), and the shade and text curves bend by their CONTRAST_CURVE_BEND; the palette is untouched, as are the text endpoints and the shade's far end. At c = 0 every knob comes back exactly as given. The numeric twin of the --_shade_lightness_00, --_shade_lightness_curve, and --_text_lightness_curve intermediates.

family

the ramp family

knobs

the family's knobs as the theme sets them

contrast

the effective contrast (effective_contrast)

type number

scheme

the scheme, which picks the ground end

returns

LightnessRampKnobs

the knobs the ramp's stops render through

CONTRAST_NAME
#

CONTRAST_PREFERENCE_NAME
#

ramps.ts view source

"_contrast_preference" import {CONTRAST_PREFERENCE_NAME} from '@fuzdev/fuz_css/ramps.js';

The private input the prefers-contrast: more mapping sets in fuz.preferences, declared 0 in the defaults. The one private variable that is an input rather than derived: the private spelling keeps a theme from setting it (the Theme schema rejects it and the renderer drops it), so a theme's --contrast can't silence the OS preference.

CSS_NUMBER_PATTERN
#

ramps.ts view source

internal

Shared by `variable.ts` and the theme modules - not stable API.

string import {CSS_NUMBER_PATTERN} from '@fuzdev/fuz_css/ramps.js';

A CSS <number> as a pattern source, stricter than what Number() accepts - no hex, binary, Infinity, or empty string.

effective_contrast
#

ramps.ts view source

(contrast: number, preference: number): number import {effective_contrast} from '@fuzdev/fuz_css/ramps.js';

The effective contrast: the larger of the theme's --contrast and the OS preference input, so a theme can author a baseline the OS raises but never lowers. The numeric twin of render_contrast_css.

contrast

the --contrast knob

type number

preference

the --_contrast_preference input, 0 unless the OS asks

type number

returns

number

HIGH_CONTRAST
#

ramps.ts view source

0.5 import {HIGH_CONTRAST} from '@fuzdev/fuz_css/ramps.js';

The value the high-contrast modifier gives the --contrast knob, and the value the prefers-contrast: more mapping gives the preference input (--_contrast_preference), so the modifier and the OS preference render the same derivation. Tuned against the floors the shipped themes hold under it: body text at 12:1 and the control border at 3:1 against the ground.

LIGHTNESS_KNOBS
#

ramps.ts view source

Readonly<Record<RampFamily, Readonly<Record<"light" | "dark", Readonly<LightnessRampKnobs>>>>>

type Readonly<Record<RampFamily, Readonly<Record<ColorScheme, Readonly<LightnessRampKnobs>>>>>

import {LIGHTNESS_KNOBS} from '@fuzdev/fuz_css/ramps.js';

The lightness ramp knobs by family, for lookups keyed on a RampFamily.

LightnessRampKnobs
#

ramps.ts view source

LightnessRampKnobs import type {LightnessRampKnobs} from '@fuzdev/fuz_css/ramps.js';

Knobs for a pow-curve lightness ramp. The endpoints are the ramp's own 00/100 stops, so light and dark schemes differ only in values, never in formula - no direction flag needed.

lightness_00

OKLCH lightness at stop 00, in [0, 1].

type number

lightness_100

OKLCH lightness at stop 100, in [0, 1].

type number

curve

Exponent bending the ramp between the endpoints; 1 is linear.

type number

NEUTRAL_CHROMA
#

ramps.ts view source

Readonly<Record<"light" | "dark", number>>

type Readonly<Record<ColorScheme, number>>

import {NEUTRAL_CHROMA} from '@fuzdev/fuz_css/ramps.js';

Peak chroma of the neutral (shade/text) scales. The neutral rides the palette's chroma shape scaled to this peak: strong tint at mid lightness, nearly untinted near white and black.

neutral_color_oklch
#

ramps.ts view source

(lightness: number, neutral_chroma: number, chroma_shape: number, hue: number, ground_chroma?: number): Oklch import {neutral_color_oklch} from '@fuzdev/fuz_css/ramps.js';

Combines resolved neutral-scale inputs into a shade/text stop's OKLCH: the peak neutral_chroma scaled by the shared chroma shape, plus the stop's share of the ground's own chroma (ground_chroma, already weighted by neutral_ground_chroma_weight; 0 past its reach and on text). The neutral twin of ramp_color_oklch, shared with check_theme for the same reason.

lightness

type number

neutral_chroma

type number

chroma_shape

type number

hue

type number

ground_chroma?

type number
optional default 0

returns

Oklch

neutral_ground_chroma_weight
#

ramps.ts view source

(family: "text" | "shade", stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100"): number import {neutral_ground_chroma_weight} from '@fuzdev/fuz_css/ramps.js';

The share of --shade_chroma_00 a neutral stop carries: 1 at the ground (shade_00), easing quadratically to 0 at SHADE_GROUND_CHROMA_REACH, and 0 for every text stop. Rounded to four places, so the emitted CSS multiplier and the numeric twins use the same number. Shared by the emitter, both numeric twins, and check_theme.

family

the neutral ramp

type "text" | "shade"

stop

the stop on it

returns

number

the weight, from 0 to 1

PALETTE_CHROMA_CAPS
#

ramps.ts view source

Readonly<Record<"light" | "dark", Readonly<Record<"00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100", number>>>>

type Readonly<Record<ColorScheme, Readonly<Record<NumericScaleVariant, number>>>>

import {PALETTE_CHROMA_CAPS} from '@fuzdev/fuz_css/ramps.js';

Worst-hue safe chroma caps per stop: the largest chroma at that stop's default lightness that stays inside sRGB for every default hue (see oklch_max_srgb_chroma for the non-convexity caveat). Computed at design time from PALETTE_HUES + PALETTE_LIGHTNESS_KNOBS, floored to stay conservative; a drift test recomputes them from the color math.

PALETTE_CHROMA_KNOBS
#

ramps.ts view source

Readonly<Record<"light" | "dark", Readonly<ChromaRampKnobs>>>

type Readonly<Record<ColorScheme, Readonly<ChromaRampKnobs>>>

import {PALETTE_CHROMA_KNOBS} from '@fuzdev/fuz_css/ramps.js';

Fitted chroma-curve knobs for the palette ramps. curve renders as the single --chroma_curve, which the neutral scales share; chroma_min and chroma_max are the palette's own.

Fitted so the requested curve hugs the effective post-clamp chroma instead of sitting above the caps through the mid-range - turning the knobs down responds immediately. Turning chroma_max up remains cap-clamped by design; --chroma_scale is the push-past-the-gamut knob. The residual vs the HSL palette this fit ports is small (mean ΔEOK ≈ 0.005 light / 0.003 dark) except light stop 30 (−0.028 C): the symmetric mid-peaked model can't reach the light cap envelope's peak there - recovering it would take an asymmetric shape (a peak-position knob).

PALETTE_CHROMA_MULTIPLIERS
#

ramps.ts view source

Readonly<Record<"a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j", number>>

type Readonly<Record<PaletteVariant, number>>

import {PALETTE_CHROMA_MULTIPLIERS} from '@fuzdev/fuz_css/ramps.js';

Per-slot chroma multipliers (--palette_X_chroma_scale), the palette's chroma-character knobs. Each multiplies its slot's chroma under the global --chroma_scale (multiplicative, so the slot's character is preserved at any global setting); values at or below 1 stay inside the worst-hue gamut caps by construction, above 1 knowingly clips like the global knob. The brown slot ships muted because brown is low-chroma dark orange - no hue angle renders it at full palette chroma.

PALETTE_HUES
#

ramps.ts view source

Readonly<Record<"a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j", number>>

type Readonly<Record<PaletteVariant, number>>

import {PALETTE_HUES} from '@fuzdev/fuz_css/ramps.js';

OKLCH hue angles for the palette slots.

PALETTE_LIGHTNESS_KNOBS
#

ramps.ts view source

Readonly<Record<"light" | "dark", Readonly<LightnessRampKnobs>>>

type Readonly<Record<ColorScheme, Readonly<LightnessRampKnobs>>>

import {PALETTE_LIGHTNESS_KNOBS} from '@fuzdev/fuz_css/ramps.js';

Fitted lightness knobs for the palette (palette_X_NN) ramps.

palette_stop_oklch
#

ramps.ts view source

(letter: "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j", stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100", scheme: "light" | "dark"): Oklch import {palette_stop_oklch} from '@fuzdev/fuz_css/ramps.js';

Computes the default OKLCH color of a palette stop (--palette_X_NN).

letter

stop

scheme

returns

Oklch

ramp_chroma
#

ramps.ts view source

(stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100", knobs: ChromaRampKnobs, cap: number): number import {ramp_chroma} from '@fuzdev/fuz_css/ramps.js';

Evaluates the palette chroma at a stop: the knob curve clamped by that stop's worst-hue cap. The --chroma_scale multipliers apply above the clamp, in ramp_color_oklch. Defaults for a scheme come from PALETTE_CHROMA_KNOBS[scheme] and PALETTE_CHROMA_CAPS[scheme][stop].

stop

knobs

cap

type number

returns

number

ramp_chroma_at_shape
#

ramps.ts view source

(shape: number, chroma_min: number, chroma_max: number, cap: number): number import {ramp_chroma_at_shape} from '@fuzdev/fuz_css/ramps.js';

The palette chroma for a resolved chroma shape: the knob range at that shape, clamped by the stop's cap - the arithmetic ramp_chroma and ThemeResolver share, the resolver supplying the shape from a theme's resolved --chroma_curve.

shape

type number

chroma_min

type number

chroma_max

type number

cap

type number

returns

number

ramp_chroma_shape
#

ramps.ts view source

(stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100", curve: number): number import {ramp_chroma_shape} from '@fuzdev/fuz_css/ramps.js';

Evaluates the normalized chroma shape pow(4t(1-t), curve) at a stop - 0 at the endpoints, 1 at the midpoint. The endpoint/midpoint guards mirror render_chroma_shape_css's exact-literal short-circuits, keeping the twins total for any curve (JS would otherwise yield 0 ** 0 === 1).

stop

curve

type number

returns

number

ramp_color_oklch
#

ramps.ts view source

(lightness: number, chroma: number, hue: number, chroma_scale?: number, slot_chroma_scale?: number): Oklch import {ramp_color_oklch} from '@fuzdev/fuz_css/ramps.js';

Combines resolved palette-ramp inputs into a color stop's OKLCH - the one formula behind --palette_X_NN/--<intent>_NN (`chroma * chroma_scale * slot multiplier` at the ramp lightness), shared by the default twins below and check_theme's theme-resolved gates so the two can't drift. Clamped as the browser clamps the oklch() it renders.

lightness

type number

chroma

type number

hue

type number

chroma_scale?

type number
optional default 1

slot_chroma_scale?

type number
optional default 1

returns

Oklch

ramp_lightness
#

ramps.ts view source

(knobs: LightnessRampKnobs, stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100"): number import {ramp_lightness} from '@fuzdev/fuz_css/ramps.js';

Evaluates a lightness ramp at a stop.

knobs

stop

returns

number

RampFamily
#

ramps.ts view source

RampFamily

type "palette" | "shade" | "text"

import type {RampFamily} from '@fuzdev/fuz_css/ramps.js';

The lightness ramp families and their CSS variable name prefixes.

render_border_color_css
#

ramps.ts view source

(): string import {render_border_color_css} from '@fuzdev/fuz_css/ramps.js';

Renders the default of the control border role (--border_color): the rest shade stop mixed in oklab toward the reach stop by border_contrast_share of the effective contrast - the rest share of reach at no contrast, all of it from HIGH_CONTRAST up.

returns

string

render_border_color_stop_css
#

ramps.ts view source

(stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100", scheme: "light" | "dark"): string import {render_border_color_stop_css} from '@fuzdev/fuz_css/ramps.js';

Renders the derived default of a border color stop (--border_color_NN): the border family's color at the stop's alpha from BORDER_COLOR_ALPHAS. The color part is scheme-agnostic - the flip lives in the referenced knobs

  • so stops whose alpha matches across schemes render identically and

variables.ts declares them single-slot.

stop

scheme

returns

string

render_chroma_shape_css
#

ramps.ts view source

(stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100"): string import {render_chroma_shape_css} from '@fuzdev/fuz_css/ramps.js';

Renders the normalized chroma shape of a stop, shared by the palette chroma ramp and the neutral scales: pow(4t(1-t), --chroma_curve). Exactly 0 at the endpoints and 1 at the midpoint.

stop

returns

string

render_chroma_stop_css
#

ramps.ts view source

(stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100", cap: number): string import {render_chroma_stop_css} from '@fuzdev/fuz_css/ramps.js';

Renders the capped default of a palette chroma ramp stop: the knob curve clamped by a worst-hue gamut cap - the baked per-scheme PALETTE_CHROMA_CAPS for the defaults, or one the theme compile step recomputed. --chroma_scale multiplies outside this clamp, at the color stops.

stop

cap

type number

returns

string

render_contrast_css
#

ramps.ts view source

(): string import {render_contrast_css} from '@fuzdev/fuz_css/ramps.js';

Renders the default of the effective contrast (--_contrast): the larger of the --contrast knob and the OS preference input. The CSS twin of effective_contrast.

returns

string

render_contrast_curve_css
#

ramps.ts view source

(family: "text" | "shade"): string import {render_contrast_curve_css} from '@fuzdev/fuz_css/ramps.js';

Renders the default of a neutral ramp's effective curve (--_shade_lightness_curve, --_text_lightness_curve): the knob bent by the family's CONTRAST_CURVE_BEND at the effective contrast. The CSS twin of contrast_lightness_curve.

family

type "text" | "shade"

returns

string

render_contrast_ground_end_css
#

ramps.ts view source

(scheme: "light" | "dark"): string import {render_contrast_ground_end_css} from '@fuzdev/fuz_css/ramps.js';

Renders a scheme's slot of the ground end (--_contrast_ground_end): CONTRAST_GROUND_END clamped to the ground, max() in light and min() in dark. The CSS twin of contrast_ground_end.

scheme

returns

string

render_contrast_ground_lightness_css
#

ramps.ts view source

(): string import {render_contrast_ground_lightness_css} from '@fuzdev/fuz_css/ramps.js';

Renders the default of the effective ground lightness (--_shade_lightness_00): the knob moved the effective contrast's fraction of the way to the ground end. The CSS twin of contrast_ground_lightness.

returns

string

render_lightness_stop_css
#

ramps.ts view source

(family: RampFamily, stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100"): string import {render_lightness_stop_css} from '@fuzdev/fuz_css/ramps.js';

Renders the derived default of an intermediate lightness ramp stop, e.g. --_palette_lightness_30: calc(var(--palette_lightness_00) + (var(--palette_lightness_100) - var(--palette_lightness_00)) * pow(0.3, var(--palette_lightness_curve))). Stops 00/100 have no derived form here. The neutral ramps read their contrast intermediates (to_lightness_stop_name, to_lightness_curve_name) in place of the shade ground and the curves.

family

stop

returns

string

render_neutral_stop_css
#

ramps.ts view source

(family: "text" | "shade", stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100"): string import {render_neutral_stop_css} from '@fuzdev/fuz_css/ramps.js';

Renders the derived default of a neutral (shade/text) stop. The neutral rides the palette's chroma shape scaled by the --neutral_chroma peak; the near-ground shade stops add their share of the ground's own tint, --_shade_ground_chroma (see neutral_ground_chroma_weight and shade_ground_chroma), since the shape is near 0 there.

family

type "text" | "shade"

stop

returns

string

render_ramp_color_css
#

ramps.ts view source

(slot: "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "accent" | "positive" | "negative" | "caution" | "info", stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | ... 4 more ... | "100", alpha?: string | undefined): string import {render_ramp_color_css} from '@fuzdev/fuz_css/ramps.js';

Renders a color derived from the palette ramps at a stop for a hue slot - the shared template behind palette stops and intent stops (--accent_50 renders with var(--hue_accent)). Both slot references are built from the slot name, so the hue (--hue_<slot>) and its chroma-character multiplier (--palette_X_chroma_scale/--<intent>_chroma_scale) stay paired in the emitted CSS by construction.

slot

a palette letter or intent name

stop

alpha?

optional CSS alpha (e.g. 40%) appended inside the oklch()

type string
optional

returns

string

render_shade_ground_chroma_css
#

ramps.ts view source

(): string import {render_shade_ground_chroma_css} from '@fuzdev/fuz_css/ramps.js';

Renders the default of the private ground tint (--_shade_ground_chroma): --shade_chroma_00 held to sRGB at the effective ground's lightness (--_shade_lightness_00). The CSS twin of shade_ground_chroma.

returns

string

render_shadow_tint_css
#

ramps.ts view source

(tint: ShadowTint): string import {render_shadow_tint_css} from '@fuzdev/fuz_css/ramps.js';

Renders a SHADOW_TINTS entry as oklch() on the neutral hue.

tint

returns

string

SHADE_CHROMA_00
#

ramps.ts view source

0 import {SHADE_CHROMA_00} from '@fuzdev/fuz_css/ramps.js';

The ground's own chroma (--shade_chroma_00), added to the near-ground stops of the shade ramp by neutral_ground_chroma_weight. The chroma shape is 0 at the endpoints, so without it the page ground is untinted whatever neutral_chroma says; a theme whose identity is a tinted page (paper, a lit night) sets it. 0 keeps the default ground neutral. The knob is the tint requested: the stops render shade_ground_chroma, the request held to sRGB at the ground's lightness, so a tint past what the ground can carry clamps rather than clipping.

shade_ground_chroma
#

ramps.ts view source

(chroma_00: number, lightness_00: number): number import {shade_ground_chroma} from '@fuzdev/fuz_css/ramps.js';

The ground tint a ground can carry: the requested --shade_chroma_00, held to sRGB at the ground's lightness by SHADE_GROUND_CHROMA_SLOPES, worst hue. The numeric twin of render_shade_ground_chroma_css, which the near-ground shade stops read in place of the knob.

chroma_00

the requested ground tint (shade_chroma_00)

type number

lightness_00

the effective ground's lightness (_shade_lightness_00)

type number

returns

number

the tint, at most chroma_00 - negative, like the CSS, for a negative request or a ground lightness outside 0..1, which the color clamp then handles as the browser does

SHADE_GROUND_CHROMA_NAME
#

ramps.ts view source

"_shade_ground_chroma" import {SHADE_GROUND_CHROMA_NAME} from '@fuzdev/fuz_css/ramps.js';

The private variable holding the ground tint the ground can carry (shade_ground_chroma).

SHADE_GROUND_CHROMA_REACH
#

ramps.ts view source

0.5 import {SHADE_GROUND_CHROMA_REACH} from '@fuzdev/fuz_css/ramps.js';

How far up the shade ramp the ground's chroma reaches, as a ramp position (0 is the ground, 1 the far end): the tint is whole at shade_00 and gone by this stop. The near-ground stops are the surfaces raised off the page - sidebars, fills, wells - and the shared chroma shape is near 0 there too, so without the reach they read gray beside a tinted ground.

SHADE_GROUND_CHROMA_SLOPES
#

ramps.ts view source

Readonly<{ light_end: number; dark_end: number; }>

type Readonly<{ light_end: number; dark_end: number; }>

import {SHADE_GROUND_CHROMA_SLOPES} from '@fuzdev/fuz_css/ramps.js';

Worst-hue sRGB chroma slopes toward the two lightness ends, bounding the ground tint (shade_ground_chroma). Each term holds where it binds: every hue holds at least light_end * (1 - L) chroma for L above about 0.730, and at least dark_end * L for L up to about 0.75, and the two cross near L 0.731 - so the tent min(light_end * (1 - L), dark_end * L) is in gamut at every lightness and hue. Fitted against oklch_max_srgb_chroma over every hue: the light-end envelope is about 0.4627 of the distance to white near L 1 and the dark end is 0.170 of the distance to black, each rounded down for a margin. The crossover sits about 0.001 above where the light term starts to hold, so raising dark_end moves it into the region the light term doesn't cover - a dark_end past the dark envelope fails the gamut property test in the dark band first.

SHADE_LIGHTNESS_KNOBS
#

ramps.ts view source

Readonly<Record<"light" | "dark", Readonly<LightnessRampKnobs>>>

type Readonly<Record<ColorScheme, Readonly<LightnessRampKnobs>>>

import {SHADE_LIGHTNESS_KNOBS} from '@fuzdev/fuz_css/ramps.js';

Lightness knobs for the shade (surface) ramps. The endpoints are fitted; the curves sit above the fit, holding the near-ground stops - the surfaces raised off the page - close to the ground in both schemes.

shade_stop_oklch
#

ramps.ts view source

(stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100", scheme: "light" | "dark"): Oklch import {shade_stop_oklch} from '@fuzdev/fuz_css/ramps.js';

Computes the default OKLCH color of a shade stop (--shade_NN).

stop

scheme

returns

Oklch

SHADOW_TINTS
#

ramps.ts view source

Readonly<Record<ShadowTint, Readonly<{ lightness: number; chroma: number; }>>>

type Readonly<Record<ShadowTint, Readonly<{ lightness: number; chroma: number; }>>>

import {SHADOW_TINTS} from '@fuzdev/fuz_css/ramps.js';

Fitted neutral-hued tints for the shadow color endpoints: bright is the light-scheme highlight and glow, dim the dark-scheme umbra and glow. Each renders on --hue_neutral, so a retinted neutral recolors shadows with the surfaces.

ShadowTint
#

ramps.ts view source

ShadowTint

type "bright" | "dim"

import type {ShadowTint} from '@fuzdev/fuz_css/ramps.js';

TEXT_LIGHTNESS_KNOBS
#

ramps.ts view source

Readonly<Record<"light" | "dark", Readonly<LightnessRampKnobs>>>

type Readonly<Record<ColorScheme, Readonly<LightnessRampKnobs>>>

import {TEXT_LIGHTNESS_KNOBS} from '@fuzdev/fuz_css/ramps.js';

Fitted lightness knobs for the text ramps.

text_stop_oklch
#

ramps.ts view source

(stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100", scheme: "light" | "dark"): Oklch import {text_stop_oklch} from '@fuzdev/fuz_css/ramps.js';

Computes the default OKLCH color of a text stop (--text_NN).

stop

scheme

returns

Oklch

to_chroma_shape_name
#

ramps.ts view source

(stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100"): string import {to_chroma_shape_name} from '@fuzdev/fuz_css/ramps.js';

The private variable holding a stop's normalized chroma shape (_chroma_shape_50).

stop

returns

string

to_lightness_curve_name
#

ramps.ts view source

(family: RampFamily): string import {to_lightness_curve_name} from '@fuzdev/fuz_css/ramps.js';

The variable a lightness ramp's curve renders through: the palette's knob (palette_lightness_curve), or for the neutral ramps the contrast-bent intermediate (_shade_lightness_curve, _text_lightness_curve).

family

returns

string

to_lightness_stop_name
#

ramps.ts view source

(family: RampFamily, stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100"): string import {to_lightness_stop_name} from '@fuzdev/fuz_css/ramps.js';

The variable a lightness ramp stop renders through: the endpoint knob itself at 00/100 (palette_lightness_00), else the private derived intermediate (_palette_lightness_30). The shade ground is the exception: its 00 stop is the contrast-adjusted intermediate _shade_lightness_00, since the effective contrast moves it off the knob.

family

stop

returns

string

to_palette_chroma_name
#

ramps.ts view source

(stop: "00" | "05" | "10" | "20" | "30" | "40" | "50" | "60" | "70" | "80" | "90" | "95" | "100"): string import {to_palette_chroma_name} from '@fuzdev/fuz_css/ramps.js';

The private variable holding a stop's capped palette chroma (_palette_chroma_50).

stop

returns

string

Depends on
#

Imported by
#