2026-06-17 11:19:31 +08:00
|
|
|
# Slider
|
|
|
|
|
|
|
|
|
|
<Preview class="w-full max-w-sm">
|
|
|
|
|
<input
|
|
|
|
|
type="range"
|
|
|
|
|
class="input w-full"
|
|
|
|
|
min="0"
|
|
|
|
|
max="100"
|
|
|
|
|
value="50"
|
|
|
|
|
/>
|
|
|
|
|
</Preview>
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
2026-06-20 13:58:42 +08:00
|
|
|
Use a native `<input type="range" class="input">`. Include `range.js` so Basecoat can keep the filled track in sync with the input value.
|
2026-06-17 11:19:31 +08:00
|
|
|
|
|
|
|
|
```html
|
2026-06-20 18:18:11 +08:00
|
|
|
<script src="https://cdn.jsdelivr.net/npm/basecoat-css@1.0.0-beta.4/dist/js/basecoat.min.js" defer></script>
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/basecoat-css@1.0.0-beta.4/dist/js/range.min.js" defer></script>
|
2026-06-17 11:19:31 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```html
|
|
|
|
|
<input type="range" class="input w-full" min="0" max="100" value="50" />
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### HTML structure
|
|
|
|
|
|
|
|
|
|
<dl>
|
2026-06-20 13:58:42 +08:00
|
|
|
<dt><code><input type="range" class="input"></code></dt>
|
2026-06-17 11:19:31 +08:00
|
|
|
<dd>Native range input styled as a slider. Width utilities such as <code>w-full</code> can be added directly.</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
Basecoat intentionally uses the native range input. Unlike shadcn/ui's Base UI slider, it does not support multiple thumbs or vertical orientation.
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
### Default
|
|
|
|
|
|
|
|
|
|
<Preview class="w-full max-w-sm">
|
|
|
|
|
<input type="range" class="input w-full" min="0" max="100" value="50" />
|
|
|
|
|
</Preview>
|
|
|
|
|
|
2026-06-20 13:58:42 +08:00
|
|
|
### Label
|
2026-06-17 11:19:31 +08:00
|
|
|
|
|
|
|
|
<Preview class="w-full max-w-sm">
|
2026-06-20 13:58:42 +08:00
|
|
|
<div class="grid w-full gap-1 max-w-sm">
|
2026-06-17 11:19:31 +08:00
|
|
|
<div class="flex items-center justify-between gap-2">
|
|
|
|
|
<label class="label" for="temperature">Temperature</label>
|
|
|
|
|
<output class="text-sm text-muted-foreground" for="temperature">50</output>
|
|
|
|
|
</div>
|
|
|
|
|
<input
|
|
|
|
|
id="temperature"
|
|
|
|
|
type="range"
|
|
|
|
|
class="input w-full"
|
|
|
|
|
min="0"
|
|
|
|
|
max="100"
|
|
|
|
|
value="50"
|
|
|
|
|
oninput="this.previousElementSibling.querySelector('output').value = this.value"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</Preview>
|
|
|
|
|
|
|
|
|
|
### Disabled
|
|
|
|
|
|
|
|
|
|
<Preview class="w-full max-w-sm">
|
|
|
|
|
<input type="range" class="input w-full" min="0" max="100" value="50" disabled />
|
|
|
|
|
</Preview>
|
|
|
|
|
|
|
|
|
|
### RTL
|
|
|
|
|
|
|
|
|
|
<Preview class="w-full max-w-sm">
|
|
|
|
|
<input type="range" class="input w-full" min="0" max="100" value="50" dir="rtl" />
|
|
|
|
|
</Preview>
|