---
title: "Slider"
description: "A slider for a number in a range."
---

> Documentation Index
> Fetch the complete documentation index at: https://gistui.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Slider

```gistui
$seats = 12
root = Stack(Slider("seats", "Seats", min:1, max:100, bind:$seats, unit:" seats"), "Monthly cost: **" + @fmt($seats * 29, "$") + "**")
```

`bind:$seats` keeps the state variable in step with the slider, so the text below updates as it moves.

## Signature

This is the line a model reads in the system prompt.

```gistui
Slider(name, label, min:num, max:num, step:num, value:num, unit:str, bind:$var, hint:str)
```

- **Group:** Forms
- **Children:** No
- **Positional arguments:** `name`, `label` (a trailing `?` means it may be left out)

## Props

| Prop | Type | How to write it | Notes |
|---|---|---|---|
| `name` | string | positional, required |  |
| `label` | string | positional, required |  |
| `min` | number | named: `min:…` |  |
| `max` | number | named: `max:…` |  |
| `step` | number | named: `step:…` |  |
| `value` | number | named: `value:…` |  |
| `unit` | string | named: `unit:…` | shown after the value, e.g. "%" |
| `bind` | `$state` variable | `bind:$name` | two-way binding to a $variable |
| `hint` | string | named: `hint:…` |  |

## Use your own component

Keep the name and schema, swap what is drawn. The prompt and the model's output do not change.

### React

```tsx
import { ui } from "@gistui/react/ui";

const lib = ui.extend({ Slider: MySlider });
<GistUI library={lib} stream={response.body} />;
```
### Vue

```vue
<GistUI :source="answer" :components="{ Slider: MySlider }" />
```
### Svelte

```svelte
<GistUI source={answer} components={{ Slider: MySlider }} />
```
### Solid

```tsx
<GistUI source={answer()} components={{ Slider: MySlider }} />
```
### Vanilla

```ts
import { ui } from "@gistui/vanilla/ui";

const lib = ui.extend({ Slider: (ctx) => ({ el: myElement(ctx) }) });
```

See [Custom components](/docs/guides/custom-components/) for the full contract. Style hook: `[data-gistui="Slider"]`.

Source: https://gistui.com/docs/components/forms/slider/index.mdx
