Overview
The <sp-color-handle>
is used to select a color on an <sp-color-area>
, <sp-color-slider>
, or <sp-color-wheel>
. It provides a draggable control point for precise color selection within color components.
Usage

Note: <sp-color-handle>
is a primitive component designed to be used within other color selection components. It's not typically used directly in applications, but rather as part of higher-level color components like <sp-color-area>
, <sp-color-slider>
, or <sp-color-wheel>
.
yarn add @spectrum-web-components/color-handle
Import the side effectful registration of <sp-color-handle>
via:
import '@spectrum-web-components/color-handle/sp-color-handle.js';
When looking to leverage the ColorHandle
base class as a type and/or for extension purposes, do so via:
import { ColorHandle } from '@spectrum-web-components/color-handle';
Anatomy
The color handle consists of several key parts:
- A visual handle element that indicates the current position
- Touch-responsive interaction areas
- Color display showing the current selected color
- Opacity checkerboard pattern for transparent colors
- An optional
sp-color-loupe
that appears above the handle when the properties open = true
and disabled = false
<sp-color-handle></sp-color-handle>
Options
Color
The color
property sets the visual color displayed within the handle. This accepts any valid CSS color format. The default color is rgba(255, 0, 0, 0.5)
(semi-transparent red).
For a complete list of supported color formats, see the ColorController documentation.
Transparency Support: When using transparent colors, the handle displays an opacity checkerboard pattern background to clearly show the transparency level.
<div style="display: flex; gap: 16px; align-items: center; margin: 16px 0;">
<div style="position: relative; height: 20px; margin: 20px;">
<sp-color-handle color="#ff0000"></sp-color-handle>
</div>
<div style="position: relative; height: 20px; margin: 20px;">
<sp-color-handle color="rgb(255, 0, 0)"></sp-color-handle>
</div>
<div style="position: relative; height: 20px; margin: 20px;">
<sp-color-handle color="rgba(255, 0, 0, 0.5)"></sp-color-handle>
</div>
<div style="position: relative; height: 20px; margin: 20px;">
<sp-color-handle color="hsl(0, 100%, 50%)"></sp-color-handle>
</div>
<div style="position: relative; height: 20px; margin: 20px;">
<sp-color-handle color="red"></sp-color-handle>
</div>
</div>
States
Standard
The default state of the color handle, ready for interaction:
<sp-color-handle></sp-color-handle>
Disabled
A disabled color handle shows that the control exists but is not available for interaction. This maintains layout continuity and communicates that the handle may become available later:
<sp-color-handle disabled></sp-color-handle>
Open
When the open
property is set, the <sp-color-loupe>
component appears above the handle to show the selected color that would otherwise be covered by a mouse, stylus, or finger on the down/touch state. The loupe automatically appears for touch input (pointerType === 'touch'
).
<div style="height: 72px"></div>
<sp-color-handle open></sp-color-handle>
Automatic Behavior: The loupe automatically opens when touched and closes when the touch interaction ends. For mouse and stylus input, the loupe remains hidden by default unless explicitly set to open="true"
.
Focused
The color handle can receive keyboard focus when used within interactive color components. The focused state is managed automatically by the parent component and is indicated visually:
<sp-color-handle focused></sp-color-handle>
Behaviors
Pointer Interactions
The color handle automatically manages pointer events to provide the optimal user experience:
- Touch Input: When touched (
pointerType === 'touch'
), the color loupe automatically appears to prevent the finger from obscuring the selected color
- Mouse/Stylus Input: The loupe remains hidden by default for precision pointing devices
- Pointer Capture: The handle captures pointer events during interaction to ensure smooth dragging even when the pointer moves outside the handle area
- Event Handling: The component listens for
pointerdown
, pointerup
, and pointercancel
events to manage the interaction lifecycle
Color Display
The handle displays the current color with proper support for transparency:
- Transparent colors are shown with an opacity checkerboard pattern background
- The color updates in real-time as the user interacts with the parent color component
- Supports all standard CSS color formats
For a complete list of supported color formats, see the ColorController documentation.
Accessibility
The <sp-color-handle>
is designed to work as part of accessible color selection components:
Keyboard Support
While the color handle itself is not directly keyboard accessible, it works in conjunction with its parent components (<sp-color-area>
, <sp-color-slider>
, <sp-color-wheel>
) which provide comprehensive keyboard navigation.
Example: Keyboard accessibility with sp-color-area
as parent component
<sp-color-area></sp-color-area>
Screen Reader Support
The color handle is rendered as a visual indicator and does not directly interface with screen readers. Accessibility is provided through the parent color component's ARIA implementation.
Touch Accessibility
- Color Loupe: Automatically appears for touch input to ensure the selected color remains visible
- Large Touch Target: The handle provides an appropriately sized touch target for mobile interaction
- Pointer Capture: Ensures reliable dragging behavior across different touch devices
Focus Management
Focus is managed by the parent color component, with the handle reflecting the focused state visually when its parent component has keyboard focus.