# Range

> Cherry Range component - validation states and label support.

Source: https://cherry.al/code/range

> For the complete documentation index, see [llms.txt](https://cherry.al/llms.txt).

# Range

<iframe className="light-only" src="https://demo.cherry.al/preview/range?theme=light" title="Range" loading="lazy" style={{ width: "100%", height: "320px", border: "1px solid var(--color-grayLight)", borderRadius: "12px" }} />
<iframe className="dark-only" src="https://demo.cherry.al/preview/range?theme=dark" title="Range" loading="lazy" style={{ width: "100%", height: "320px", border: "1px solid var(--color-grayLight)", borderRadius: "12px" }} />

Range inputs allow users to select a value from a range. Range accepts the `$label`, `$size`, `$error`, `$success`, `$fullWidth`, and `$wrapperClassName` properties also found on the Input component, but not `$icon` or `$iconPosition`, and the native `size` attribute is omitted. Range can have error or success states to provide feedback to the user.

Keep in mind that the `<input>` element inherently includes native browser properties like `min`, `max`, `step`, and `onChange`. Cherry UI components introduce custom properties that always begin with a `$` to distinguish them from native props. Range also forwards its `ref` to the underlying `<input type="range">` element.

For design guidelines and all interactive states, see the [Inputs](/inputs) design page.

```jsx
import React from "react";
import { Range } from "cherry-styled-components";

export default function Page() {
  return <Range />;
}
```

With a label:

```html
<Range id="volume" $label="Label" $fullWidth />
```

The label is only associated with the input when an `id` is passed, so include one whenever you use `$label`.

With native `min`, `max`, and `step` attributes and a controlled value:

```jsx
const [value, setValue] = React.useState(50);

<Range
  min={0}
  max={100}
  step={5}
  value={value}
  onChange={(e) => setValue(Number(e.target.value))}
/>;
```

With different sizes:

```html
<Range $size="small" />
<Range $size="big" />
```

With success and error states:

```html
<Range $success />
<Range $error />
```

Disabled ranges get dedicated styling with a gray track and thumb and a `not-allowed` cursor:

```html
<Range disabled />
```

## Properties

<Field value="$label" type="string">
  Label text displayed above the range. Pass an `id` on the Range so the label
  is associated with the input.
</Field>

<Field value="$size" type='"default" | "big" | "small"'>
  Size of the range slider.
</Field>

<Field value="$error" type="boolean">
  Shows error state styling and sets `aria-invalid` on the input.
</Field>

<Field value="$success" type="boolean">
  Shows success state styling.
</Field>

<Field value="$fullWidth" type="boolean">
  Makes the range span the full width of its container.
</Field>

<Field value="$wrapperClassName" type="string">
  Class name applied to the wrapper element around the range slider, for restyling from the outside.
</Field>

<Button href="https://github.com/cherry-design-system/styled-components/blob/main/src/lib/range.tsx" icon="code" iconPosition="left">
  View Source
</Button>
