> ## Documentation Index
> Fetch the complete documentation index at: https://araf.badr.co.id/llms.txt
> Use this file to discover all available pages before exploring further.

# Slider

> A draggable range input for selecting a numeric value or range along a track — supports single value, range, step, and disabled states.

## Overview

<div style={{display:"flex",flexDirection:"column",gap:"24px",padding:"28px 24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"8px"}}>
    <div style={{display:"flex",justifyContent:"space-between",alignItems:"center"}}>
      <span style={{fontSize:"13px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Volume</span>
      <span style={{fontSize:"13px",color:"#667085",fontFamily:"Inter,sans-serif"}}>60</span>
    </div>

    <div style={{position:"relative",height:"6px",background:"#E5E7EB",borderRadius:"3px"}}>
      <div style={{position:"absolute",left:0,top:0,height:"6px",width:"60%",background:"#0479CE",borderRadius:"3px"}} />

      <div style={{position:"absolute",left:"calc(60% - 9px)",top:"-6px",width:"18px",height:"18px",borderRadius:"50%",background:"#fff",border:"2px solid #0479CE",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}} />
    </div>
  </div>

  <div style={{display:"flex",flexDirection:"column",gap:"8px"}}>
    <div style={{display:"flex",justifyContent:"space-between",alignItems:"center"}}>
      <span style={{fontSize:"13px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Price range</span>
      <span style={{fontSize:"13px",color:"#667085",fontFamily:"Inter,sans-serif"}}>$20 – $80</span>
    </div>

    <div style={{position:"relative",height:"6px",background:"#E5E7EB",borderRadius:"3px"}}>
      <div style={{position:"absolute",left:"20%",top:0,height:"6px",width:"60%",background:"#0479CE",borderRadius:"3px"}} />

      <div style={{position:"absolute",left:"calc(20% - 9px)",top:"-6px",width:"18px",height:"18px",borderRadius:"50%",background:"#fff",border:"2px solid #0479CE",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}} />

      <div style={{position:"absolute",left:"calc(80% - 9px)",top:"-6px",width:"18px",height:"18px",borderRadius:"50%",background:"#fff",border:"2px solid #0479CE",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}} />
    </div>
  </div>
</div>

**Slider** lets users select a value or range by dragging a thumb along a track. Use it for settings like volume, brightness, or price range filters.

***

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install @araf-ds/core
  ```

  ```bash yarn theme={null}
  yarn add @araf-ds/core
  ```

  ```bash pnpm theme={null}
  pnpm add @araf-ds/core
  ```
</CodeGroup>

***

## Usage

```tsx theme={null}
import { Slider } from "@araf-ds/core"

export default function Example() {
  return (
    <Slider defaultValue={[50]} min={0} max={100} label="Volume" showValue />
  )
}
```

***

## Variants

### Basic

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"8px",maxWidth:"320px"}}>
    <span style={{fontSize:"13px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Volume</span>

    <div style={{position:"relative",height:"6px",background:"#E5E7EB",borderRadius:"3px"}}>
      <div style={{position:"absolute",left:0,top:0,height:"6px",width:"50%",background:"#0479CE",borderRadius:"3px"}} />

      <div style={{position:"absolute",left:"calc(50% - 9px)",top:"-6px",width:"18px",height:"18px",borderRadius:"50%",background:"#fff",border:"2px solid #0479CE",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}} />
    </div>
  </div>
</div>

```tsx theme={null}
<Slider defaultValue={[50]} min={0} max={100} label="Volume" />
```

### With Value Display

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"8px",maxWidth:"320px"}}>
    <div style={{display:"flex",justifyContent:"space-between"}}>
      <span style={{fontSize:"13px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Brightness</span>
      <span style={{fontSize:"13px",color:"#667085",fontFamily:"Inter,sans-serif"}}>30</span>
    </div>

    <div style={{position:"relative",height:"6px",background:"#E5E7EB",borderRadius:"3px"}}>
      <div style={{position:"absolute",left:0,top:0,height:"6px",width:"30%",background:"#0479CE",borderRadius:"3px"}} />

      <div style={{position:"absolute",left:"calc(30% - 9px)",top:"-6px",width:"18px",height:"18px",borderRadius:"50%",background:"#fff",border:"2px solid #0479CE",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}} />
    </div>
  </div>
</div>

```tsx theme={null}
<Slider defaultValue={[30]} label="Brightness" showValue />
```

### Range Slider

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"8px",maxWidth:"320px"}}>
    <div style={{display:"flex",justifyContent:"space-between"}}>
      <span style={{fontSize:"13px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Price range</span>
      <span style={{fontSize:"13px",color:"#667085",fontFamily:"Inter,sans-serif"}}>$20 – $80</span>
    </div>

    <div style={{position:"relative",height:"6px",background:"#E5E7EB",borderRadius:"3px"}}>
      <div style={{position:"absolute",left:"20%",top:0,height:"6px",width:"60%",background:"#0479CE",borderRadius:"3px"}} />

      <div style={{position:"absolute",left:"calc(20% - 9px)",top:"-6px",width:"18px",height:"18px",borderRadius:"50%",background:"#fff",border:"2px solid #0479CE",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}} />

      <div style={{position:"absolute",left:"calc(80% - 9px)",top:"-6px",width:"18px",height:"18px",borderRadius:"50%",background:"#fff",border:"2px solid #0479CE",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}} />
    </div>
  </div>
</div>

```tsx theme={null}
<Slider defaultValue={[20, 80]} label="Price range" showValue />
```

### Disabled

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"8px",maxWidth:"320px",opacity:0.5,cursor:"not-allowed"}}>
    <span style={{fontSize:"13px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Locked setting</span>

    <div style={{position:"relative",height:"6px",background:"#E5E7EB",borderRadius:"3px"}}>
      <div style={{position:"absolute",left:0,top:0,height:"6px",width:"40%",background:"#D0D5DD",borderRadius:"3px"}} />

      <div style={{position:"absolute",left:"calc(40% - 9px)",top:"-6px",width:"18px",height:"18px",borderRadius:"50%",background:"#F9FAFB",border:"2px solid #D0D5DD",boxShadow:"none"}} />
    </div>
  </div>
</div>

```tsx theme={null}
<Slider defaultValue={[40]} disabled label="Locked setting" />
```

***

## API Reference

<ParamField path="value" type="number[]">
  Controlled value(s). One element for single, two elements for range.
</ParamField>

<ParamField path="defaultValue" type="number[]" default="[0]">
  Uncontrolled default value.
</ParamField>

<ParamField path="onValueChange" type="(value: number[]) => void">
  Callback fired when the value changes while dragging.
</ParamField>

<ParamField path="min" type="number" default="0">
  Minimum value.
</ParamField>

<ParamField path="max" type="number" default="100">
  Maximum value.
</ParamField>

<ParamField path="step" type="number" default="1">
  Increment step between values.
</ParamField>

<ParamField path="label" type="string">
  Label shown above the slider.
</ParamField>

<ParamField path="showValue" type="boolean" default="false">
  Displays the current value next to the label.
</ParamField>

<ParamField path="disabled" type="boolean" default="false">
  Disables the slider.
</ParamField>

<ParamField path="orientation" type="string" default="horizontal">
  Layout orientation. Values: `horizontal` · `vertical`
</ParamField>

<ParamField path="className" type="string">
  Additional Tailwind classes for custom overrides.
</ParamField>

***

## Accessibility

* Slider uses `role="slider"` with `aria-valuenow`, `aria-valuemin`, and `aria-valuemax`
* Arrow keys move the thumb by one step; Page Up/Down move by 10% of the range
* Home/End keys jump to minimum/maximum
* Range sliders have two separate thumb elements, each keyboard-navigable
* `disabled` uses `aria-disabled="true"` and removes the element from tab order
* Label is associated via `aria-labelledby`

***

## Do's & Don'ts

<CardGroup cols={2}>
  <Card title="Do" icon="check" iconType="solid" color="#16A34A">
    * Use Slider for continuous numeric values where precision isn't critical
    * Always show the current value with `showValue` when precision matters
    * Use `step` to constrain values to meaningful increments
    * Use a range Slider for min/max filtering (price, date)
  </Card>

  <Card title="Don't" icon="xmark" iconType="solid" color="#DC2626">
    * Don't use Slider when an exact value must be entered — use a number Input
    * Don't use very small steps on a short track — it becomes imprecise
    * Don't use Slider for binary on/off settings — use Switch instead
    * Don't omit a label — the track alone does not convey meaning
  </Card>
</CardGroup>
