# Slider

> Two sliders for film work: a playhead you scrub along a frame ruler with the timecode above it, and a fader with a unity detent and an exact value beside it.

Source: https://kwark.space/designSystem/components/slider

## Usage

### What it is
Kwark has two sliders, and both come from the cutting room, not from a settings page.

- **Playhead scrub**: a ruler of frames under a timecode. Second ticks are tall, quarter-second ticks short, and the playhead is the same accent line with a cap that the [Playhead and scrubber](https://kwark.space/designSystem/components/playhead.md) uses on the timeline. Dragging anywhere on the ruler moves it; the timecode above it is the value.
- **Fader**: a level, drawn as a mixing-desk fader cap on a thin rail, with marks at −24, −12, −6, **0** and +6 dB. 0 is the detent (unity) and is drawn heavier. An exact field beside the label takes typed values.

### When to use
- **Scrub**: finding a moment in a scene, a clip or an animatic; trimming a shot’s in and out on a storyboard frame.
- **Fader**: a continuous value a person judges by ear or eye, where nearby values are equally fine: dialogue and music gain, a preview’s opacity.

### When not to
- A value that has to be exact (a page count, a lens in millimetres): use the [Number stepper](https://kwark.space/designSystem/components/number-stepper.md).
- Choosing from a few named options: a [Segmented control](https://kwark.space/designSystem/components/segmented-control.md).
- Long material on a phone: a slider over an hour of footage is too coarse. Pair it with a timecode field and frame steps.

### Behaviour
- Scrubbing previews live; the position is not an edit and is not an undo step.
- A fader previews while dragging and commits one undo step when released, not one per pixel.
- The exact field and the fader are one value: typing −3 moves the cap; moving the cap writes −3.
- Values snap to the detent within half a step of 0 dB when dragged, never when typed.

**Do:** A frame ruler with 00:00:05:08 above it, and a fader whose 0 dB mark is heavier than the rest.

**Don't:** A round blue thumb on a filled bar with no units, that reads the same for gain, zoom and progress.

## Style

### Anatomy

### Playhead scrub
1. **Card**: `--k-surface`, 1px line, 10px corners, 12px 16px padding.
2. **Head**: scene number in 600 and heading in 12px `--k-text-2`; timecode as `<output>` in Poppins 600 `--k-fs-head` (20px), tabular, HH:MM:SS:FF.
3. **Ruler**: 44px (52 on touch), 6px corners, a step above the card with an inset 1px line. Second ticks 14px in `--k-text-2`; quarter-second ticks 7px in `--k-line-strong`. Labels in 11px tabular under the ticks.
4. **Playhead**: 2px `--k-accent` line, 4px past the ruler top and bottom, with a 12 × 8px cap. 3px wide on hover.
5. **Foot**: frame count and frame rate; the keys in small keycaps.

### Fader
1. **Rail**: 4px, `--k-raise` with an inset 1px line. No fill: a desk fader shows position, not quantity.
2. **Cap**: 14 × 26px, 3px corners, `--k-surface` with a 1px `--k-text` edge and an ink core (an inset, not a glow). Pressed: the edge and core take `--k-accent`.
3. **Marks**: 4px ticks with 11px tabular labels; the detent tick is 2px wide in `--k-text` and its label 600.
4. **Exact field**: 30px, 5.5 characters, 600 16px right-aligned, unit after it in 12px.

### Tokens

| Token | Light | Dark |
|---|---|---|
| `--k-surface` | #ffffff | #1a1a1a |
| `--k-raise` | #f1f5f9 | #252525 |
| `--k-line` | #e2e8f0 | rgba(255, 255, 255, .1) |
| `--k-line-strong` | var(--k-text-2) | var(--k-text-2) |
| `--k-text` | #0f172a | #e3e3e3 |
| `--k-text-2` | #5b6779 | #9ca3af |
| `--k-accent` | #98633f | #98633f |
| `--k-accent-soft` | #e8b58b | #e8b58b |
| `--k-focus` | #0f172a | #f4f4f5 |
| `--k-fs-head` | 20px |  |
| `--k-fs-dense` | 11px |  |
| `--k-radius-card` | 10px |  |
| `--k-radius-control` | 6px |  |

## Code

### React

Use the HTML below with `kwark.css`. The example shows the markup and styling. Supply any application behavior described on this page.

### HTML and CSS

Works anywhere with `kwark.css`.

```html
<div class="kw-playscrub" data-sequence-demo>
  <div class="kw-playscrub__head"><span class="kw-playscrub__scene"><b>Scene 12</b> · INT. EDIT SUITE – NIGHT</span><output class="kw-playscrub__tc">00:00:05:08</output></div>
  <div class="kw-playscrub__ruler">
    <span class="kw-playscrub__ticks" aria-hidden="true"></span>
    <span class="kw-playscrub__labels" aria-hidden="true"><span>0:00</span><span>0:02</span><span>0:04</span><span>0:06</span><span>0:08</span><span>0:10</span></span>
    <input class="kw-playscrub__input" type="range" min="0" max="240" step="1" value="128" aria-label="Playhead in Scene 12">
    <span class="kw-playhead" aria-hidden="true"></span>
  </div>
  <div class="kw-playscrub__foot"><span>Frame 128 of 240 · 24 fps</span><span><kbd>←</kbd> <kbd>→</kbd> one frame · <kbd>Shift</kbd> one second</span></div>
</div>
<div class="kw-specimen-row">
  <div class="kw-fader" data-gain-demo>
    <div class="kw-fader__top"><span class="kw-label">Dialogue gain</span><label class="kw-fader__exact"><span class="kw-visually-hidden">Exact dialogue gain</span><input type="number" min="-24" max="6" step="0.5" value="-3"><span>dB</span></label></div>
    <div class="kw-fader__rail"><input class="kw-fader__range" type="range" min="-24" max="6" step="0.5" value="-3" aria-label="Dialogue gain" aria-valuetext="-3 dB"></div>
    <div class="kw-fader__marks" aria-hidden="true"><span style="left:0%">−24</span><span style="left:40%">−12</span><span style="left:60%">−6</span><span class="is-detent" style="left:80%">0</span><span style="left:100%">+6</span></div>
  </div>
  <div class="kw-fader kw-fader--disabled">
    <div class="kw-fader__top"><span class="kw-label">Music gain</span><span class="kw-hint">Locked while the stems export</span></div>
    <div class="kw-fader__rail"><input class="kw-fader__range" type="range" min="-24" max="6" step="0.5" value="-9" aria-label="Music gain" aria-valuetext="-9 dB" disabled></div>
    <div class="kw-fader__marks" aria-hidden="true"><span style="left:0%">−24</span><span style="left:40%">−12</span><span style="left:60%">−6</span><span class="is-detent" style="left:80%">0</span><span style="left:100%">+6</span></div>
  </div>
</div>
```

### Behaviour to supply
- Frames: `timecode = [h, m, s, frame % fps]` from `frame / fps`, each padded to two digits. Set `aria-valuetext` to the timecode and the rate on every change (the site’s demo does this with `data-sequence-demo`).
- Arrow keys step one frame; Shift + Arrow one second; Home and End the first and last frame.
- Fader: keep the range and the exact field in step (the demo’s `data-gain-demo`), and set `aria-valuetext` with the unit: *−3 dB*.
- Commit the fader on `change`, preview on `input`.

## Accessibility

### Keyboard
| Key | Scrub | Fader |
|---|---|---|
| Left / Right | One frame | One step (0.5 dB) |
| Shift + Left / Right | One second | 3 dB |
| Home / End | First / last frame | −24 / +6 dB |
| Page Up / Down | Ten seconds | 6 dB |

### Roles and names
- Both are native `<input type="range">`, so phones and screen readers get a real slider. The drawn ruler, ticks and playhead are `aria-hidden`.
- Names include the object: *Playhead in Scene 12*, *Dialogue gain*.
- `aria-valuetext` speaks the value as people say it: *00:00:05:08 at 24 frames per second*, *−3 dB*.
- The fader’s exact field has its own name (*Exact dialogue gain*) and is the precise route for people who cannot drag.
- Focus shows a 2px ring around the playhead or the cap’s rail. Disabled faders say why in words beside the label.

## For agents

### Rules

- **Must** use a native range input underneath any drawn ruler, playhead or fader cap.
- **Must** set aria-valuetext with the unit or timecode on every change.
- **Always** pair a fader with an exact field when the value matters; never make dragging the only way.
- **Never** draw a slider as a filled progress bar or a round glowing thumb.
- **Always** show timecode as HH:MM:SS:FF in tabular Poppins figures with the frame rate stated.
- **Must** commit a fader as one undo step on release, not one per movement.

### AI readiness test

**Task:** Add a scrubber to an animatic preview of Scene 12 and a dialogue gain control.

**Give the agent:** Slider, Playhead and scrubber, Waveform.

**Constraint:** 24 fps, ten seconds long; gain from −24 to +6 dB.

**A reliable answer:**
- Native range under a frame ruler
- Timecode output in HH:MM:SS:FF
- Arrow steps one frame
- Fader with 0 dB detent and an exact field
- aria-valuetext with units
