SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

Color foundations

What @sdxc/ui/color is for, the native-control and labelling rules its parts share, and every variable it reads.

Color inputs: swatches, a swatch picker, a saturation area, a hue wheel, channel sliders, a validated field and a popover picker.

Each is a native control underneath, so it submits with a form and works by keyboard before script loads.

typescript
import "@sdxc/ui/theme.css";
import { … } from "@sdxc/ui/color";

When to reach for it

  • A brand, accent or theme color setting in a form.
  • Labels, tags or calendars a user colors from a preset palette.
  • A design tool or editor that needs every channel, alpha included.

Shared ideas

  • Native controlsArea, wheel and sliders are <input type="range">; the swatch picker is radios.
  • Labels requiredColorWheel, ColorArea and ColorPicker.Trigger warn in development without an accessible name.
  • TargetsSlider inputs and swatch options grow to --ui-target-size, 44px on a coarse pointer.
  • DirectionGradients flip under :dir(rtl); an area's vertical axis keeps low at the bottom.
  • MotionThumb transitions are instant under prefers-reduced-motion.
  • Server firstThe server renders working controls; colorWheelDrag(), colorAreaDrag() and colorPreview() add gestures.

CSS variables

Every custom property the namespace reads or declares, with its default and what it controls.

Reads the neutral role for borders, checkerboards and fills, and brand for focus rings, checked swatches and thumb borders. The roles are documented on Theming.

Sizes

None is declared in theme.css; set any of them on the control or an ancestor.

VariableDefaultWhat it controls
--ui-color-swatch-size-sm1.25remSize of a swatch with size="sm".
--ui-color-swatch-size-md1.75remSize of a swatch at the default size.
--ui-color-swatch-size-lg2.5remSize of a swatch with size="lg".
--ui-color-swatch-checker-size0.625remCheckerboard cell behind a translucent swatch.
--ui-color-picker-trigger-size2.25remSize of the button that opens a ColorPicker.
--ui-color-area-size16remWidth and height of a ColorArea.
--ui-color-area-thumb-thickness0.1875remWidth of the line each of the area's thumbs draws.
--ui-color-wheel-size12remDiameter of a round ColorWheel.
--ui-color-wheel-thumb-size1.25remWheel thumb size, the ring's thickness and the plain bar's height.
--ui-color-wheel-thumb-border-width2pxBorder of the wheel's thumb.
--ui-color-slider-thumb-size1.25remSlider thumb size and the track's height.
--ui-color-slider-thumb-border-width2pxBorder of a slider's thumb.
--ui-color-slider-checker-size0.625remCheckerboard cell behind an alpha track.
--ui-target-size1.5rem; 2.75rem on a coarse pointerSmallest pointer target a slider or swatch option keeps.

Shape and elevation

Read through @sdxc/u's rounded() and shadow(); each default is the fallback an app overrides by declaring the variable.

VariableDefaultWhat it controls
--ui-radius-none0pxCorners of a shape="square" swatch.
--ui-radius-md0.375remCorners of an area, a rounded swatch and the picker's trigger.
--ui-radius-full9999pxCorners of the wheel, slider tracks, thumbs and round swatches.
--ui-shadow-base0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)Lift under every thumb.

Set by the components

Written from a control's value or props, or by a mixin, and read back by its own parts. Leave them unset.

VariableDefaultWhat it controls
--ui-color-swatch-valueset by ColorSwatch from valueThe color a swatch shows; colorPreview() rewrites it while typing.
--ui-color-area-hueset by ColorArea from hueHue of the area's base layer.
--ui-color-wheel-hue, --ui-color-wheel-valueset by ColorWheel from its valueAngle the thumb turns to and the hue its border shows.
--ui-color-slider-hueset by ColorSlider.Track from hueHue a saturation, lightness or alpha gradient is painted at.
--ui-color-wheel-track-direction, --ui-color-slider-track-directionright; left in right-to-left textDirection a hue bar's or slider's gradient runs.
--ui-color-slider-channel-<channel>written by channelSync()Each sibling channel's value, for a custom track gradient to read.
@sdxc/ui

Can’t find it? Contact us