Vize

Color Wheel

Headless Color Wheel; covers Adobe React Aria ColorWheel, React Spectrum ColorWheel.

Package @vizejs/ui/color-wheel
Maturity stable
Quality gates behavior contract, mounted dom, type inference, tree shaking, bundle size, ssr, hydration, dom compile, ssr compile, vapor compile
Bundle budget 6,000 B JS gzip / 0 B CSS gzip
Own the source vize lib pull color-wheel
Requires —
Aliases hue wheel, color hue, polar hue
Covers Adobe React Aria ColorWheel, React Spectrum ColorWheel

Minimal setup

Use a Vue 3.5+ project with Vue SFC compilation configured (see Vite+ integration).

vp install @vizejs/ui

Add the public import below to <script setup lang="ts">. Components provide behavior without styles; the preview uses optional Paper styles.

import { ColorWheel } from "@vizejs/ui/color-wheel";

Or copy the source into your project with vize lib pull color-wheel (see Source Distribution).

Try it

This is the basic example maintained with the component source, using the public package imports. The preview adds the optional Paper styles.

Open the interactive example · Styling these components

Copy the example

<!-- Controlled hue wheel with the selected color named beside it. -->
<script setup lang="ts">
import { ref } from "vue";

import { ColorWheel } from "@vizejs/ui/color-wheel";

const hue = ref(200);
</script>

<template>
  <ColorWheel v-slot="{ color, hue: current }" v-model="hue" label="Hue">
    <output>{{ current }} {{ color }}</output>
  </ColorWheel>
</template>

A clockwise hue, with 0 at the right

ColorWheel is a slider for hue. The geometry matches a screen: 0° is the right-hand point, and the angle increases clockwise because y grows downward. Arrow keys step by 1°. Shift and Page Up / Page Down step by 10°. Home is 0. End is 360, the same color as 0, so a full turn is representable.

<script setup lang="ts">
import { ref } from "vue";

import { ColorWheel } from "@vizejs/ui/color-wheel";

const hue = ref(200);
</script>

<template>
  <ColorWheel v-model="hue" label="Hue" />
</template>

The root sets --vize-color-wheel-hue. The marker is [data-part="marker"]. Dragging uses pointer capture. Nothing reads window during setup, so the marker position is stable across SSR and hydration.

API

ColorWheel

Source: src/components/color-wheel/color-wheel.vue

Props

Prop Type Default Description
modelValue number 0 Hue in degrees. 0 and 360 are the same color; End sets 360.
label string "Hue" Accessible name of the slider.
disabled boolean false Ignore pointer and keyboard changes.

Events

Event Payload Description
update:modelValue [hue: number] Fired when the hue changes from the keyboard or the pointer. Carries the next hue in degrees.

Slots

Slot Slot props Description
default ColorWheelSlotProps Renders inside the wheel with the current hue and an hsl() color.

Exposed

Member Type Description
focus —

Behavior

Normative state × input → outcome table for src/components/color-wheel/color-wheel.vue. Hue 0 is the positive x axis. Screen y grows downward, so the wheel runs clockwise. Every row is proven by src/components/color-wheel/tests/behavior.test.ts.

# State Input Outcome Proven by
C1 geometry point on +x, +y, -x, -y hues 0, 90, 180, 270 maps screen axes to a clockwise hue
C2 hue 0 render slider named Hue, value 0, marker at the right (86, 50) renders hue 0 at the right of the wheel
C3 hue 0 ArrowRight / ArrowLeft 1 / 359, and the key is canceled steps hue from the arrow keys and wraps
C4 hue 40 Home / End 0 / 360 sends Home to 0 and End to 360
C5 hue 0 Shift+ArrowRight, then PageDown, then PageUp 10, then 0, then 10 uses a ten-degree step for Shift and Page keys
C6 enabled pointer down at the right of the center hue 0 reads the pointer as a clockwise hue
C7 disabled render, ArrowRight, pointer aria-disabled, not tabbable, no change disabled wheel ignores keyboard and pointer
C8 any default slot slot receives hue and an hsl() color passes hue and color to the slot