Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sl-multi-range component #1912

Draft
wants to merge 19 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions docs/pages/components/multi-range.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
meta:
title: Multi-Range
description: Multi-Ranges allow the user to select multiple values within a given range using a slider with multiple handles.
layout: component
---

```html:preview
<sl-multi-range></sl-multi-range>
```

```jsx:react
import SlRange from '@shoelace-style/shoelace/dist/react/multi-range';

const App = () => <SlRange />;
```

## Examples

### Min, Max, and Step

Use the `min` and `max` attributes to set the range's minimum and maximum values, respectively. The `step` attribute determines the value's interval when increasing and decreasing.

```html:preview
<sl-multi-range min="1" max="10" step="1" value="[0,10]"></sl-multi-range>
```

{% raw %}

```jsx:react
import SlRange from '@shoelace-style/shoelace/dist/react/multi-range';

const App = () => <SlRange min={1} max={10} step={1} value={[0,10]}/>;
```

{% endraw %}

### Disabled

Use the `disabled` attribute to disable a slider.

```html:preview
<sl-multi-range disabled></sl-multi-range>
```

```jsx:react
import SlRange from '@shoelace-style/shoelace/dist/react/multi-range';

const App = () => <SlRange disabled />;
```

### Arbitrary Number of Handles

You can use any number of handles on the slider. The slider will have one handle for every element in the value array.

```html:preview
<sl-multi-range value="[25,50,75]"></sl-multi-range>
```

{% raw %}

```jsx:react
import SlRange from '@shoelace-style/shoelace/dist/react/multi-range';

const App = () => <SlRange value={[25,50,75]} />;
```

{% endraw %}

### Label and Help Text

You can add an accessible label and/or descriptive help text using the `label` and `help-text` attributes or slots.

```html:preview
<sl-multi-range label="Difficulty Range" help-text="Search for challenges within the desired difficulty range"></sl-multi-range>
```

```jsx:react
import SlRange from '@shoelace-style/shoelace/dist/react/multi-range';

const App = () => <SlRange label="Difficulty Range" help-text"Search for challenges within the desired difficulty range" />;
```

### Custom Track Colors

You can customize the active and inactive portions of the track using the `--track-color-active` and `--track-color-inactive` custom properties.

```html:preview
<sl-multi-range
value="[25,75]"
style="
--track-color-active: var(--sl-color-green-300);
--track-color-inactive: var(--sl-color-red-300);
"
></sl-multi-range>
```

{% raw %}

```jsx:react
import SlRange from '@shoelace-style/shoelace/dist/react/multi-range';

const App = () => <SlRange value={[25,75]} style={{
'--track-color-active': 'var(--sl-color-green-300)',
'--track-color-inactive': 'var(--sl-color-red-300)'
}}/>;
```

{% endraw %}
Loading
Loading