sdxc

Type to search, or start from one of these:

ColorWheel

A circular hue picker.

210°#318fed

Drag around the ring, or focus it and step with the arrow keys.

View code
let hue = 210;

<div mix={[hstack({ gap: 5, align: "center" })]}>
	<ColorWheel
		aria-label="Accent hue"
		name="accentHue"
		value={hue}
		step={1}
		mix={[
			colorWheelDrag(),
			on<HTMLDivElement, "ui:color-wheel-change">("ui:color-wheel-change", (event) => {
				hue = event.hue;
				void handle.update();
			}),
		]}
	/>

	<div mix={[vstack({ gap: 3, align: "start" })]}>
		<Label>Accent hue</Label>
		<div mix={[hstack({ gap: 2, align: "center" })]}>
			<ColorSwatch size="lg" shape="circle" value={tint} />
			<div mix={[vstack({ gap: 0, align: "start" })]}>
				<span mix={[font("mono"), text("sm"), weight("medium")]}>{Math.round(hue)}°</span>
				<span mix={[font("mono"), text("xs"), fg("neutral")]}>{tint}</span>
			</div>
		</div>
		<p mix={[text("sm"), fg("neutral")]}>
			Drag around the ring, or focus it and step with the arrow keys.
		</p>
	</div>
</div>

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

npm add @sdxc/ui
import "@sdxc/ui/theme.css";

Usage

import { ColorWheel } from "@sdxc/ui";

Renders a root <div> around a single <input type="range"> across hue's 0360 domain, carrying every accessibility and form semantic this wheel exposes; colorWheelDrag() enables the ring rendering.

Examples

<ColorWheel aria-label={t("theme.accentHue")} value={hue} name="hue" disabled={isLocked} />

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeDescription
value?numberCurrent hue, in degrees 0360, for a wheel a consumer tracks itself.
defaultValue?numberStarting hue, in degrees 0360, for a wheel left to the platform's own uncontrolled state.
step?numberDegrees a single keypress moves the value by. Defaults to DEFAULT_STEP.
name?stringNative name submitted with an enclosing form.
form?stringNative id of the form the underlying hue input associates with, when it sits outside that form's own markup.
disabled?booleanMarks the underlying hue input inert and excluded from the tab order.
parts?PartsPropsPer-part styling for this wrapper's internally composed hue input.

Also accepts everything in Omit<TagProps<"div">, "children">.