nercone.dev about links contact sitemap
about links sitemap 82 ffc6419

Colors

Every color is a custom property. The palette is in color.css; the colors by purpose come from the theme.

Hover a swatch to see its variable name. Click it to copy the color; the control above each panel chooses the format. The swatches show the colors of the current theme.

Base colors

Every palette starts from one of these. The hues are hwb() colors with a whiteness of 20% and no blackness; only the angle differs.

VariableValue
--color-blackhwb(0 0% 100%)
--color-whitehwb(0 100% 0%)
--color-greyhwb(0 50% 50%)
--color-redhwb(0 20% 0%)
--color-orangehwb(25 20% 0%)
--color-yellowhwb(50 20% 0%)
--color-greenhwb(155 20% 0%)
--color-cyanhwb(190 20% 0%)
--color-skyhwb(210 20% 0%)
--color-bluehwb(230 20% 0%)
--color-purplehwb(270 20% 0%)
--color-pinkhwb(320 20% 0%)
--color-starkSet by the theme: --color-white in dark themes, --color-black in light themes

stark is the color with the most contrast against the background. Use it for things that should stand out the most, such as the logo on the loading overlay and the tint of the hero.

Palette

Each palette has 41 steps in increments of 5. From 0 to 100, the base color is mixed with black: 0 is black and 100 is the base color. From 100 to 200, it is mixed with white: 200 is white. Refer to a step as --color-{name}-{step}.

Click a swatch to copy it as
grey
red
orange
yellow
green
cyan
sky
blue
purple
pink
stark

Because stark is already white in dark themes and black in light themes, half of its steps are the same color: stark-100 to stark-200 are all white in dark themes, and stark-0 to stark-100 are all black in light themes.

Brightness

Frequently used steps have names. For the hues, -dark is step 45, -normal is 75, and -bright is 100. For grey, whose base color is already a middle grey, they are 25, 50, and 75.

Click a swatch to copy it as

The components use -bright for text and -normal for borders, as in the status buttons and the alert blocks.

Opacity

--color-{name}-opacity-{step} is the base color mixed with transparent: 0 is transparent and 100 is the base color. There are 21 steps in increments of 5. Besides the palettes, black and white have them as well.

Click a swatch to copy it as
black
white
grey
red
orange
yellow
green
cyan
sky
blue
purple
pink
stark

Translucent colors take on the color of what is behind them, so they work on any background. The themes use white-opacity-* and black-opacity-* for text, layers, and borders.

JIS safety colors

--color-jis-{name} are the safety colors of JIS Z 9103:2018, in sRGB. Their meaning depends on their exact color, so they have no palette, brightness, or opacity steps; use them as they are. The UD themes use them for the status colors.

Click a swatch to copy it as

Colors by purpose

Pages and components use these instead of the palette. They are defined by the theme, so a page follows the theme without changes. See Themes for how each theme sets them.

Click a swatch to copy it as
Base
Status
Alerts
VariableUse
--color-foregroundText
--color-foreground-altHeadings, <strong>, and text that should stand out
--color-backgroundThe page
--color-background-altOpaque surfaces above the page, such as popups and toasts
--color-layer, --color-layer-altTranslucent areas, such as layer and table headers
--color-border, --color-border-altBorders
--color-{information,success,warning,error}-*Status of buttons and toasts
--color-{note,tip,important,warning,caution}-*Alerts: block-* and layer-*, and the > [!NOTE] alerts of Markdown pages

Each component also has its own colors, --color-{component}-*, such as --color-button-primary-background and --color-toast-error-border. They refer to the colors above, so most pages never need to change them. They are listed on the page of each component.

Utility classes

Classes set the text color (fg-color- or text-color-), the background color (bg-color- or background-color-), and the border color (bd-color- or border-color-) to a color. They are declared with !important.

ColorsExample
Palette steps of grey and the huesfg-color-red-130
Brightness of the huesbg-color-blue-dark
Opacity steps of black, white, grey, and the huesbg-color-white-opacity-10
JIS safety colorsfg-color-jis-red
Status and alert colorsbd-color-warning-normal

The base colors, the stark palette, the brightness of grey, the base colors by purpose (foreground, layer, and so on), and the component colors have no classes. Use their variables instead.

red-bright orange-bright yellow-bright green-bright cyan-bright sky-bright blue-bright purple-bright pink-bright

bg-color-blue-opacity-10
bd-color-green-normal
All three combined
<span class="fg-color-red-bright">…</span>
<div class="block bg-color-purple-opacity-10 bd-color-purple-normal">…</div>

Overriding colors

The variables can be set on any element, and the new value applies to that element and its descendants. Change the colors by purpose or the component colors, not the palette, so that the change follows the theme.

.pink {
    --color-button-primary-background: var(--color-pink-bright);
    --color-button-primary-border:     var(--color-pink-bright);
    --color-slider:                    var(--color-pink-bright);
    --color-slider-thumb:              var(--color-pink-bright);
}

Swatch

The swatches on this page are a component. swatch shows --swatch-color above its content, over a checkerboard that shows transparency. swatch-compact is smaller and centered.

div.swatch

With swatch.js, clicking an element with data-swatch="--color-…" copies that color and shows a toast. The nearest data-swatch-format on it or an ancestor chooses the format: variable (var(--color-…), the default), rgb, or hex. rgb and hex are computed in sRGB from the element, so they follow the theme; colors outside sRGB cannot be copied as them.

.sky { --swatch-color: var(--color-sky-bright); }

<div data-swatch-format="hex">
    <button class="swatch sky" type="button" data-swatch="--color-sky-bright"><span>sky-bright</span></button>
</div>
const swatch = window.nercone.get('swatch');
await swatch.copy(element);        // true when copied
await swatch.copy(element, 'rgb'); // in another format

Change the height of the color with --swatch-height (default 48px), the padding of the content with --swatch-padding (default 4px 8px), the size of the checkerboard with --swatch-checker-size (default 12px), and the colors with --color-swatch-*. The options of swatch.js are on Scripts.