Kinetik UI

Gradient Slider

.md

A colour slider on a hue or white-balance gradient with a ring knob, a live swatch and an action button.

v1.0.0Live on webreact-native-gesture-handlerreact-native-reanimatedreact-native-worklets
Component preview

Installation

Kinetik CLI
npx kinetik-ui add gradient-slider

The CLI copies the source and installs native dependencies with npx expo install, so versions match your Expo SDK. With shadcn: npx shadcn@latest add https://kinetik-ui.dev/r/gradient-slider.json

Install manually

  1. Install dependencies
    npx expo install react-native-gesture-handler react-native-reanimated react-native-worklets
  2. Copy the source files
    • components/kinetik/gradient-slider.tsx
    View source files

Usage

import { GradientSlider } from '@/components/kinetik/gradient-slider';

<GradientSlider
  label="Hue"
  stops="hue"
  min={0}
  max={360}
  step={1}
  value={hue}
  onValueChange={(value, color) => {
    setHue(value);
    setTint(color);
  }}
/>;

<GradientSlider
  label="Temperature"
  stops="temperature"
  min={2000}
  max={10000}
  step={100}
  value={kelvin}
  onValueChange={setKelvin}
  action={{ icon: <TargetIcon />, label: 'Reset white balance', onPress: () => setKelvin(5500) }}
/>;

When to use

  • Picking a hue, a white balance or any value that is easiest to read as colour.
  • Photo and design editors where the result changes live.

When not to use

  • Exact colours: give people a hex field or a full colour picker as well.
  • Values that are not colours: a coloured track suggests the colour matters.

Notes

  • stops takes hue, temperature or your own [hue, saturation, lightness] stops. colorAt(stops, t) returns the colour at any point as hsl().
  • The swatch shows when there is no action; set swatch to show both.

Props

GradientSliderProps

PropTypeDefaultDescription
valuerequirednumber—
labelrequiredstring—Accessible name.
onValueChange(value: number, color: string) => void—Called with the stepped value and the colour under the knob while dragging.
onSlidingComplete(value: number, color: string) => void—
minnumber0Defaults to 0.
maxnumber1Defaults to 1.
stepnumber—Snap interval. Defaults to 1/100 of the range.
stopskeyof typeof GRADIENT_PRESETS | readonly HslStop[]'hue'A preset name or your own stops, left to right. Defaults to `hue`.
formatValue(value: number) => string—
swatchboolean—Show a swatch of the picked colour at the end. Defaults to true without an `action`.
actionGradientSliderAction—A round button at the end, e.g. reset.
disabledbooleanfalse
hapticsbooleantrueA tick at both ends. Defaults to true.
styleStyleProp<ViewStyle>—

Performance and accessibility

Performance

Budget
The gradient is a static background; the knob moves on the UI thread and its colour updates once per step.
Measured

Pixel 9 emulator, API 35, release build · interaction median 1.00× the system Settings app on the same emulator (indicative only) · no frames drawn at rest · 158 MB app memory

Real-device measurement pending.

Accessibility

Reduced motion
The knob follows the finger without growing and the swatch changes without popping.
Screen readers
Adjustable role with min, max, current value and formatted text. The swatch is decorative; the action button has its own name.
Touch target
The track is 44 pt tall; the swatch area and action button are at least 44 pt.

Source files

components/kinetik/gradient-slider.tsx is in the Code tab of the preview above.