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
Lightness
Temperature
Lightness range
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, labelEndDisabled
disabled
The Swatch size scale
Each channel is exactly as tall as its neighbouring Swatch. Width remains flexible.
2xsxssmbaselgxl2xl3xl4xl5xl6xl7xl
Install and use
Update local state on every move. Run expensive work in onValueCommitted.
npm i @patternmode/channelimport { 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