Skip to content

Color Slider

A slider for hue, opacity, or another color channel.

Anatomy

  • #track: Content inside the generated gradient track. Receives value and channel.
  • #thumb: Decorative thumb content. Receives value, channelValue, and percentage.

Usage

Hue and opacity

Change hue and opacity with separate sliders. Both update the same color value.

#56d799

Vertical and RTL

Vertical tracks increase upward. RTL reverses horizontal pointer and arrow direction.

OKLCH and read-only

Use a smaller step for OKLCH chroma. Read-only sliders accept focus but prevent changes.

Examples

Hue and opacity

Change hue and opacity with separate sliders. Both update the same color value.

vue
<Dialog
  :ui="{
    overlay: 'fixed inset-0 bg-black/50 backdrop-blur-sm',
    content: 'bg-white rounded-xl shadow-xl w-full max-w-md',
    header: 'flex items-center justify-between p-6 border-b',
    body: 'p-6',
    footer: 'flex justify-end gap-2 p-6 border-t',
  }"
>

Vertical and RTL

Vertical tracks increase upward. RTL reverses horizontal pointer and arrow direction.

vue
import './main.css'

OKLCH and read-only

Use a smaller step for OKLCH chroma. Read-only sliders accept keyboard focus but prevent changes.

vue
<template>
  <Accordion
    :items="items"
    type="multiple"
  />
</template>

See the live demo's code for the state and style objects used in these examples.

Formats

Set format to choose the returned color string. It does not change which colors you can enter or which channels you edit. See supported formats. Changing the format keeps opacity and emits value-change with reason format. HEX uses eight digits for transparent colors; hexa uses eight digits for all colors.

HEX and RGB can lose colors outside sRGB. The control keeps the original color until you replace the model or enter a new value. Area and slider previews use sRGB. See precision and gamut for details.

Use a color value such as #56d799 or oklch(0.65 0.2 250). CSS variables, currentColor, and relative color expressions are not supported.

Behavior

The slider uses a visually hidden native range input for keyboard and screen reader support. Style the visible track and thumb through ui.

For a keyboard focus ring on the thumb, set ui.axis to peer outline-none and use peer-data-[akaza-focus-visible] classes on ui.thumb. The root and axis expose data-akaza-focus-visible for keyboard focus. data-akaza-focused also includes focus from a pointer.

For a vertical slider, give the root a height and the track a width and full height.

Hue tracks stay visible for gray and transparent colors. Other channel tracks show opaque colors. The alpha track shows transparency against your background. The component positions the thumb; do not add transforms to position it.

The thumb exposes --akaza-color but does not force a background. Use ui.thumb: 'bg-white' for a white handle, or bg-[var(--akaza-color)] for a color-filled handle.

API Reference

Props

PropTypeDefaultPurpose
modelValuestring"#ff0000"Selected CSS color. Bind with v-model.
formatColorFormat"hex"Format for the returned and submitted color string.
id, namestringFrom FieldInput ID and form field name.
required, disabled, readOnly, invalidbooleanfalseNative validation and interaction states; disabled/required also inherit from Field.
ariaLabel, ariaLabelledby, ariaDescribedbystringFrom Field where applicableAccessible naming and description.
uiComponent UI object-Classes for the named parts below.
channelColorChannel"hue"Channel to edit.
colorSpaceColorSpace"hsb"Space used for channel interpretation.
stepnumberChannel defaultIncrement; OKLCH chroma defaults to 0.001.
orientation"horizontal" | "vertical""horizontal"Layout and pointer axis.
dir"ltr" | "rtl""ltr"Horizontal reading direction.
invertedbooleanfalseReverse the visual scale.

Emits

EventPayloadMeaning
update:modelValueSelected colorVue model update.
value-change(value, details)Runs before a change. Use details.cancel() to stop it. Includes reason and the native event when available.
value-commit(value, details)Runs when an interaction ends. Canceling it does not undo the value change.

Slots

  • #track: Content inside the generated gradient track. Receives value and channel.
  • #thumb: Decorative thumb content. Receives value, channelValue, and percentage.

UI Options

KeyElement
rootPointer surface
trackComputed channel gradient
thumbVisual position and selected color
axisKeyboard and assistive-technology control
inputForm input for the full color value

Styling Hooks

UI keyCSS classData attributes / semantics
rootakaza-color-sliderShared form flags; data-akaza-channel, data-akaza-orientation, data-akaza-dragging, data-akaza-focus-visible
trackakaza-color-slider-track-
thumbakaza-color-slider-thumbaria-hidden
axisakaza-color-slider-axisNative range/slider attributes; data-akaza-focus-visible
inputakaza-color-slider-inputNative validation attributes

Form state attributes: data-akaza-disabled, data-akaza-readonly, data-akaza-invalid, data-akaza-focused, data-akaza-touched, data-akaza-dirty, data-akaza-filled, and data-akaza-out-of-gamut. Each appears only when true.

Use class or ui.root to style the root. Use the other ui keys for inner parts. Set sizes, borders, and colors in your own styles.

Keyboard

KeyBehavior
Arrow keysAdjust by one step; horizontal arrows follow RTL/inversion.
PageUp / PageDown, Shift+ArrowAdjust by ten steps.
Home / EndSet the channel minimum/maximum.
TabEnter/leave the slider, including readonly sliders. Disabled sliders are skipped.

Parity Notes

ColorSlider combines Reka's root, track, and thumb parts in one component. Use ui, #track, and #thumb to customize them. The supplied Base UI reference has no color slider component.

Edit this page on GitHub ↗