Channel

A gradient slider for one colour channel, with glass thumbs. One value or a range. Your app supplies the gradient and the colour maths.

@patternmode/channel

Lightness62
Temperature#CDB398
Lightness range30 to 70

Reference

States and variants

Sizes follow Swatch, base is 32px and xl is 48px. Endpoint captions are optional.

  • One value, base size

    size="base"
  • Thumb contrast from your rule

    getThumbColor(value, index)
  • Endpoint captions

    labelStart, labelEnd
  • Disabled

    disabled

The Swatch size scale

Each channel is exactly as tall as its neighbouring Swatch. Width remains flexible.

  • 2xs
  • xs
  • sm
  • base
  • lg
  • xl
  • 2xl
  • 3xl
  • 4xl
  • 5xl
  • 6xl
  • 7xl

Install and use

Update local state on every move. Run expensive work in onValueCommitted.

npm i @patternmode/channel
import { ChannelSlider } from "@patternmode/channel";
import "@patternmode/channel/styles.css";

<ChannelSlider
  label="Lightness"
  background="linear-gradient(to right, #fff, #000)"
  size="xl"
  value={lightness}
  onValueChange={setLightness}
  onValueCommitted={search}
  getThumbColor={(value) => value < 50 ? "#000" : "#fff"}
  labelStart="Lighter"
  labelEnd="Darker"
/>

Keyboard and accessibility

Built on Base UI, which handles focus, keys, pointer input and forms.

label
Names the slider. In a range the thumbs become "start" and "end"; thumbLabels renames them.
getValueText
Announces values in your own words, such as "warmer" rather than a number.
step, largeStep
How far the arrow keys and the larger keyboard steps move a thumb.
Reduced motion
The press animation follows the reduced motion setting.

Package

Package
@patternmode/channel
Version
0.2.7
Needs
react, react-dom
Licence
MIT