# @salmonui/inputs/slider API reference

> 11 exported symbols of @salmonui/inputs/slider: 1 component, 6 interfaces and 4 types.

Canonical: https://salmonui.dev/docs/reference/inputs/slider

```ts
import { … } from '@salmonui/inputs/slider';
```

## Components

### Slider

Kind: component

Page: https://salmonui.dev/docs/reference/inputs/slider/Slider

```ts
function Slider<T extends SliderValue = number>(props: SliderProps<T>): ReactNode;
```

Slider: single or two-thumb range on native range inputs,
ticks, value labels, limits, vertical orientation and RTL mirroring.
`ref` is the root element.

Props: [`SliderProps`](https://salmonui.dev/docs/reference/inputs/slider/SliderProps) (its members are the props)

## Interfaces

### SliderChangeDetails

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/slider/SliderChangeDetails

```ts
interface SliderChangeDetails {
    readonly source: 'pointer' | 'touch' | 'keyboard' | 'api';
    readonly reason: 'drag' | 'keyboard' | 'input' | 'reset';
    readonly thumb: 0 | 1;
}
```

Second argument of `onValueChange` and `onValueCommit`.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: 'pointer' \| 'touch' \| 'keyboard' \| 'api';` |  |  |
| `reason` | `readonly reason: 'drag' \| 'keyboard' \| 'input' \| 'reset';` |  | `'drag'` (pointer), `'keyboard'` (arrow, Page, Home, End keys), `'input'` (a native input event, e.g. assistive technology) or `'reset'` (form reset). |
| `thumb` | `readonly thumb: 0 \| 1;` |  | The thumb that moved: 0 (single or start) or 1 (end). |

### SliderLimits

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/slider/SliderLimits

```ts
interface SliderLimits {
    readonly minStart?: number | undefined;
    readonly maxStart?: number | undefined;
    readonly minEnd?: number | undefined;
    readonly maxEnd?: number | undefined;
    readonly startFixed?: boolean | undefined;
    readonly endFixed?: boolean | undefined;
}
```

Thumb bounds inside `min..max`; `startFixed` / `endFixed` lock a thumb.

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `minStart` | `readonly minStart?: number \| undefined;` | optional |  |
| `maxStart` | `readonly maxStart?: number \| undefined;` | optional |  |
| `minEnd` | `readonly minEnd?: number \| undefined;` | optional |  |
| `maxEnd` | `readonly maxEnd?: number \| undefined;` | optional |  |
| `startFixed` | `readonly startFixed?: boolean \| undefined;` | optional |  |
| `endFixed` | `readonly endFixed?: boolean \| undefined;` | optional |  |

### SliderProps

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/slider/SliderProps

```ts
interface SliderProps<T extends SliderValue = number> extends FieldCommonProps {
    readonly value?: T | undefined;
    readonly defaultValue?: T | undefined;
    readonly onValueChange?: ((value: SliderValueOf<T>, details: SliderChangeDetails) => void) | undefined;
    readonly onValueCommit?: ((value: SliderValueOf<T>, details: SliderChangeDetails) => void) | undefined;
    readonly min?: number | undefined;
    readonly max?: number | undefined;
    readonly step?: number | undefined;
    readonly pageStep?: number | undefined;
    readonly values?: readonly SliderScalar[] | undefined;
    readonly minStepsBetweenThumbs?: number | undefined;
    readonly fill?: boolean | undefined;
    readonly orientation?: 'horizontal' | 'vertical' | undefined;
    readonly ticks?: SliderTicks | undefined;
    readonly renderTick?: ((ctx: SliderTickContext) => ReactNode) | undefined;
    readonly valueLabel?: SliderValueLabel | undefined;
    readonly formatOptions?: Intl.NumberFormatOptions | undefined;
    readonly locale?: string | undefined;
    readonly limits?: SliderLimits | undefined;
    readonly name?: string | undefined;
    readonly form?: string | undefined;
    readonly disabled?: boolean | undefined;
    readonly readOnly?: boolean | undefined;
    readonly localeText?: SliderLocaleText | undefined;
    readonly id?: string | undefined;
    readonly dir?: 'ltr' | 'rtl' | 'auto' | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly classNames?: {
        readonly label?: string;
        readonly control?: string;
        readonly track?: string;
        readonly range?: string;
        readonly thumb?: string;
        readonly valueLabel?: string;
        readonly ticks?: string;
        readonly tick?: string;
        readonly description?: string;
        readonly error?: string;
    } | undefined;
    readonly ref?: Ref<HTMLDivElement> | undefined;
}
```

Members (36):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `value` | `readonly value?: T \| undefined;` | optional | Controlled value: a number (or `values` entry), or `[start, end]` for two thumbs. |
| `defaultValue` | `readonly defaultValue?: T \| undefined;` | optional | Default `min` (`[min, max]` for a range is chosen by passing a tuple). |
| `onValueChange` | `readonly onValueChange?: ((value: SliderValueOf<T>, details: SliderChangeDetails) => void) \| undefined;` | optional | While the value changes; at most once per animation frame during a drag. |
| `onValueCommit` | `readonly onValueCommit?: ((value: SliderValueOf<T>, details: SliderChangeDetails) => void) \| undefined;` | optional | When a drag ends (pointerup) or a key is released. |
| `min` | `readonly min?: number \| undefined;` | optional | Default 0. |
| `max` | `readonly max?: number \| undefined;` | optional | Default 100. |
| `step` | `readonly step?: number \| undefined;` | optional | Default 1. |
| `pageStep` | `readonly pageStep?: number \| undefined;` | optional | PageUp / PageDown distance. Default a tenth of the range rounded to `step` (at least `step`). |
| `values` | `readonly values?: readonly SliderScalar[] \| undefined;` | optional | Discrete entries; the value is an entry and `min` / `max` / `step` are ignored. |
| `minStepsBetweenThumbs` | `readonly minStepsBetweenThumbs?: number \| undefined;` | optional | Smallest distance between the thumbs of a range, in steps. Default 0. |
| `fill` | `readonly fill?: boolean \| undefined;` | optional | Fills the track from `min` to the thumb. A range always fills between its thumbs. |
| `orientation` | `readonly orientation?: 'horizontal' \| 'vertical' \| undefined;` | optional |  |
| `ticks` | `readonly ticks?: SliderTicks \| undefined;` | optional |  |
| `renderTick` | `readonly renderTick?: ((ctx: SliderTickContext) => ReactNode) \| undefined;` | optional | Tick content; default the label of major ticks. |
| `valueLabel` | `readonly valueLabel?: SliderValueLabel \| undefined;` | optional |  |
| `formatOptions` | `readonly formatOptions?: Intl.NumberFormatOptions \| undefined;` | optional | `Intl.NumberFormat` options of `aria-valuetext` and the default labels. |
| `locale` | `readonly locale?: string \| undefined;` | optional | Formatting locale. Default `'en-US'`; the host locale is never read. |
| `limits` | `readonly limits?: SliderLimits \| undefined;` | optional |  |
| `name` | `readonly name?: string \| undefined;` | optional |  |
| `form` | `readonly form?: string \| undefined;` | optional |  |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional |  |
| `readOnly` | `readonly readOnly?: boolean \| undefined;` | optional | Focusable, announced, but not changeable. |
| `localeText` | `readonly localeText?: SliderLocaleText \| undefined;` | optional |  |
| `id` | `readonly id?: string \| undefined;` | optional |  |
| `dir` | `readonly dir?: 'ltr' \| 'rtl' \| 'auto' \| undefined;` | optional |  |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |
| `classNames` | `readonly classNames?: {     readonly label?: string;     readonly control?: string;     readonly track?: string;     readonly range?: string;     readonly thumb?: string;     readonly valueLabel?: string;     readonly ticks?: string;     readonly tick?: string;     readonly description?: string;     readonly error?: string; } \| undefined;` | optional | Part classes: `root` is `className`. |
| `ref` | `readonly ref?: Ref<HTMLDivElement> \| undefined;` | optional | The root element. |
| `label` | `label?: ReactNode;` | optional, inherited |  |
| `description` | `description?: ReactNode;` | optional, inherited |  |
| `errorMessage` | `errorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) \| ReactNode;` | optional, inherited | Error text (or a function of the errors) shown while the field is invalid. |
| `invalid` | `invalid?: boolean;` | optional, inherited | Forces the error state. |
| `validation` | `validation?: FieldValidation;` | optional, inherited | Rules in the Data Grid vocabulary. |
| `validateOn` | `validateOn?: ValidateOn;` | optional, inherited | When errors appear; default the `Form`'s, else `'blur'`. |
| `size` | `size?: FieldSize;` | optional, inherited | Metric set. Default `'md'`. |

### SliderTickContext

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/slider/SliderTickContext

```ts
interface SliderTickContext {
    readonly value: SliderScalar;
    readonly label: string;
    readonly major: boolean;
    readonly percent: number;
}
```

Argument of `renderTick`.

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `value` | `readonly value: SliderScalar;` |  |  |
| `label` | `readonly label: string;` |  | The formatted label. |
| `major` | `readonly major: boolean;` |  |  |
| `percent` | `readonly percent: number;` |  | Position along the track, 0..100. |

### SliderTicks

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/slider/SliderTicks

```ts
interface SliderTicks {
    readonly placement?: 'before' | 'after' | 'both' | 'none' | undefined;
    readonly majorStep?: number | undefined;
    readonly minorStep?: number | undefined;
    readonly showMinor?: boolean | undefined;
    readonly formatOptions?: Intl.NumberFormatOptions | undefined;
}
```

Tick marks.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `placement` | `readonly placement?: 'before' \| 'after' \| 'both' \| 'none' \| undefined;` | optional | Side of the track. Default `'after'`. |
| `majorStep` | `readonly majorStep?: number \| undefined;` | optional | Distance between labelled major ticks. Default 10 (1 with `values`). |
| `minorStep` | `readonly minorStep?: number \| undefined;` | optional | Distance between minor ticks. Default 1. |
| `showMinor` | `readonly showMinor?: boolean \| undefined;` | optional | Draws minor ticks between the major ones. Default false. |
| `formatOptions` | `readonly formatOptions?: Intl.NumberFormatOptions \| undefined;` | optional | `Intl.NumberFormat` options of the tick labels. Default the slider's `formatOptions`. |

### SliderValueLabel

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/slider/SliderValueLabel

```ts
interface SliderValueLabel {
    readonly show?: 'focus' | 'hover' | 'always' | 'never' | undefined;
    readonly placement?: 'before' | 'after' | undefined;
    readonly formatOptions?: Intl.NumberFormatOptions | undefined;
    readonly format?: ((value: SliderScalar) => string) | undefined;
}
```

The value bubble over each thumb.

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `show` | `readonly show?: 'focus' \| 'hover' \| 'always' \| 'never' \| undefined;` | optional | When the bubble shows. Default `'focus'` (focus or hover). |
| `placement` | `readonly placement?: 'before' \| 'after' \| undefined;` | optional | Above (`'before'`) or below the thumb; start / end for vertical sliders. Default `'before'`. |
| `formatOptions` | `readonly formatOptions?: Intl.NumberFormatOptions \| undefined;` | optional |  |
| `format` | `readonly format?: ((value: SliderScalar) => string) \| undefined;` | optional | Bubble text. |

## Types

### SliderLocaleText

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/slider/SliderLocaleText

```ts
type SliderLocaleText = FieldValidationText & {
    readonly start?: string;
    readonly end?: string;
};
```

User-visible strings: `start` / `end` name the thumbs of a range slider.

Members (19):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `validationCreditcard` | `validationCreditcard?: string;` | optional, inherited |  |
| `validationDate` | `validationDate?: string;` | optional, inherited |  |
| `validationDateIso` | `validationDateIso?: string;` | optional, inherited |  |
| `validationDigits` | `validationDigits?: string;` | optional, inherited |  |
| `validationEmail` | `validationEmail?: string;` | optional, inherited |  |
| `validationMax` | `validationMax?: string;` | optional, inherited |  |
| `validationMaxLength` | `validationMaxLength?: string;` | optional, inherited |  |
| `validationMin` | `validationMin?: string;` | optional, inherited |  |
| `validationMinLength` | `validationMinLength?: string;` | optional, inherited |  |
| `validationNumber` | `validationNumber?: string;` | optional, inherited |  |
| `validationPattern` | `validationPattern?: string;` | optional, inherited |  |
| `validationRange` | `validationRange?: string;` | optional, inherited |  |
| `validationRangeLength` | `validationRangeLength?: string;` | optional, inherited |  |
| `validationRequired` | `validationRequired?: string;` | optional, inherited |  |
| `validationTel` | `validationTel?: string;` | optional, inherited |  |
| `validationUrl` | `validationUrl?: string;` | optional, inherited |  |
| `validationValidate` | `validationValidate?: string;` | optional, inherited |  |
| `start` | `start?: string;` | optional, inherited |  |
| `end` | `end?: string;` | optional, inherited |  |

### SliderScalar

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/slider/SliderScalar

```ts
type SliderScalar = number | string;
```

One slider value: a number, or an entry of `values`.

### SliderValue

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/slider/SliderValue

```ts
type SliderValue = SliderScalar | readonly [
    SliderScalar,
    SliderScalar
];
```

A single value or a `[start, end]` range.

### SliderValueOf

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/slider/SliderValueOf

```ts
type SliderValueOf<V> = V extends readonly [
    infer A,
    infer B
] ? readonly [
    SliderValueOf<A>,
    SliderValueOf<B>
] : V extends number ? number : V extends string ? string : V;
```

The value type callbacks receive: literals widened (`50` -> `number`).
