PeakUIPro

CellSlider

Range slider styled as a settings cell

Usage

import {CellSlider} from "@peakui-pro/react";

Anatomy

The Label names the slider and the Output reads its value, whatever order they are written in.

import {CellSlider} from "@peakui-pro/react";

// Rendered as: the hoisted Label, then every other part in the order it was written.
// The slider is always horizontal — `orientation` is not accepted.
export default () => (
  <CellSlider defaultValue={30}>
    <CellSlider.Label>Volume</CellSlider.Label>
    <CellSlider.Track>
      <CellSlider.Fill />
      <CellSlider.Thumb />
    </CellSlider.Track>
    <CellSlider.Output />
  </CellSlider>
);

Examples

Variants

variant restyles the row and its fill together.

Controlled

Settings Group

The row's leading label names the slider; the cell fills the value column.

Secondary Group

Integer Step

Disabled

Customization

Tailwind CSS

<CellSlider className="w-full" defaultValue={30}>
  <CellSlider.Track>…</CellSlider.Track>
</CellSlider>

Global CSS

@layer components {
  /* The default fill's tint; the edge borders follow it through the data-fill states. */
  .cell-slider[data-orientation="horizontal"] .cell-slider__track[data-fill-start="true"] {
    --cell-slider-fill: var(--default);
    border-inline-start-color: var(--default);
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The CellSlider component uses these CSS classes (view source styles):

Base Classes

  • .cell-slider - The root; fills the row a settings table gives it

Element Classes

  • .cell-slider__track - The visible cell row; a surface 36px high the label and the value sit inside
  • .cell-slider__track--default - The default track variant
  • .cell-slider__track--secondary - A quieter row: bg-default-soft with no surface shadow
  • .cell-slider__fill - The value's tint, one tone-step darker than its track
  • .cell-slider__thumb - A transparent hit area; the visible thumb is its ::after pill
  • .cell-slider__label - The leading label, positioned over the track's start
  • .cell-slider__output - The value display, positioned over the track's end

Slots

  • [data-slot="cell-slider"] - The root element
  • [data-slot="cell-slider-track"] - The row
  • [data-slot="cell-slider-fill"] - The fill
  • [data-slot="cell-slider-thumb"] - The thumb's hit area
  • [data-slot="cell-slider-label"] - The label
  • [data-slot="cell-slider-output"] - The value display

CSS Variables

VariablePurpose
--cell-slider-fillThe fill's tint at the default variant, set through the track's data-fill-* states

API Reference

CellSlider

PropTypeDefaultDescription
variant'default' | 'secondary''default'The cell's own variant axis; the core Slider beneath it has none
childrenReactNode-The parts; Label parts are hoisted ahead of the rest
classNamestring-Additional classes
renderDOMRenderFunction<'div', SliderRenderProps>-Replaces the rendered <div> with your own element
...restComponentProps<typeof SliderRoot>-The core Slider root's props minus orientation, which is locked to 'horizontal': value, defaultValue, onChange, minValue, maxValue, step, isDisabled, aria-label and the rest of React Aria's Slider attributes

CellSlider.Track

PropTypeDefaultDescription
childrenReactNode | ((values) => ReactNode)-The Fill and the Thumb
classNamestring-Additional classes
renderDOMRenderFunction<'div', SliderTrackRenderProps>-Replaces the rendered <div> with your own element
...restComponentProps<typeof SliderTrack>-The core Slider.Track's props, React Aria's SliderTrack attributes among them

CellSlider.Fill

PropTypeDefaultDescription
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element; E defaults to 'div'
...restComponentProps<typeof SliderFill<"div">>-The core Slider.Fill's props, native <div> attributes among them

CellSlider.Thumb

PropTypeDefaultDescription
childrenReactNode | ((values) => ReactNode)-Custom thumb content; the pill renders without it
classNamestring-Additional classes
renderDOMRenderFunction<'div', SliderThumbRenderProps>-Replaces the rendered <div> with your own element
...restComponentProps<typeof SliderThumb>-The core Slider.Thumb's props, React Aria's SliderThumb attributes among them

CellSlider.Label

PropTypeDefaultDescription
childrenReactNode-The label text; names the slider unless you named it some other way
classNamestring-Additional classes
renderDOMRenderFunction<'span', undefined>-Replaces the rendered <span> with your own element
...restComponentProps<'span'>-Native <span> attributes

CellSlider.Output

PropTypeDefaultDescription
childrenReactNode | ((values) => ReactNode)-Custom content; the slider's value renders without it
classNamestring-Additional classes
renderDOMRenderFunction<'output', SliderOutputRenderProps>-Replaces the rendered <output> with your own element
...restComponentProps<typeof SliderOutput>-The core Slider.Output's props, React Aria's SliderOutput attributes among them

On this page