v1.3.0 28

Slider

An input where the user selects a value from within a given range.

Interactive Requires: veritheme.js JS init: automatic

Default

html
<input class="vt-slider" type="range" min="0" max="100" value="50" aria-label="Value">

With Value Label

html
75%
50%
<div>
  <div class="vt-flex vt-justify-between vt-items-center vt-mb-3">
    <label class="vt-label" for="slider-2-1">Volume</label>
    <span id="volume-val" class="vt-body-sm vt-text-foreground-muted">75%</span>
  </div>
  <input class="vt-slider" type="range" min="0" max="100" value="75" oninput="document.getElementById('volume-val').textContent=this.value+'%'" id="slider-2-1">
</div>
<div>
  <div class="vt-flex vt-justify-between vt-items-center vt-mb-3">
    <label class="vt-label" for="slider-2-2">Brightness</label>
    <span id="brightness-val" class="vt-body-sm vt-text-foreground-muted">50%</span>
  </div>
  <input class="vt-slider" type="range" min="0" max="100" value="50" oninput="document.getElementById('brightness-val').textContent=this.value+'%'" id="slider-2-2">
</div>

With Steps

Slider snapping to discrete values.

html
20°C
16°C 23°C 30°C
<div class="vt-flex vt-justify-between vt-items-center vt-mb-3">
  <label class="vt-label" for="slider-3-1">Temperature</label>
  <span id="temp-val" class="vt-text-sm vt-font-mono vt-text-foreground-muted">20°C</span>
</div>
<input class="vt-slider" type="range" min="16" max="30" step="1" value="20" oninput="document.getElementById('temp-val').textContent=this.value+'°C'" id="slider-3-1">
<div class="vt-flex vt-justify-between vt-caption vt-text-foreground-muted vt-mt-2">
  <span>16°C</span>
  <span>23°C</span>
  <span>30°C</span>
</div>

Disabled

html
<input class="vt-slider" type="range" min="0" max="100" value="40" disabled="" aria-label="Value">

Settings Example

html

Audio Settings

Configure audio output.

80%
60%
45%
<div class="vt-card vt-max-w-md">
  <div class="vt-card-header">
    <h3 class="vt-card-title">Audio Settings</h3>
    <p class="vt-card-description">Configure audio output.</p>
  </div>
  <div class="vt-card-body">
    <div class="vt-space-y-6">
      <div>
        <div class="vt-flex vt-justify-between vt-items-center vt-mb-2">
          <label class="vt-label vt-flex vt-items-center vt-gap-2" for="slider-5-1">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" class="vt-w-4 vt-h-4 vt-text-foreground-muted" aria-hidden="true">
              <path d="M14 14.8135V9.18646C14 6.04126 14 4.46866 13.0747 4.0773C12.1494 3.68593 11.0603 4.79793 8.88232 7.02192C7.75439 8.17365 7.11085 8.42869 5.50604 8.42869C4.10257 8.42869 3.40084 8.42869 2.89675 8.77262C1.85035 9.48655 2.00852 10.882 2.00852 12C2.00852 13.118 1.85035 14.5134 2.89675 15.2274C3.40084 15.5713 4.10257 15.5713 5.50604 15.5713C7.11085 15.5713 7.75439 15.8264 8.88232 16.9781C11.0603 19.2021 12.1494 20.3141 13.0747 19.9227C14 19.5313 14 17.9587 14 14.8135Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path><path d="M17 9C17.6254 9.81968 18 10.8634 18 12C18 13.1366 17.6254 14.1803 17 15" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path><path d="M20 7C21.2508 8.36613 22 10.1057 22 12C22 13.8943 21.2508 15.6339 20 17" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path>
            </svg>
            Master
          </label>
          <span id="master-val" class="vt-text-sm vt-tabular-nums vt-text-foreground-muted">80%</span>
        </div>
        <input class="vt-slider" type="range" min="0" max="100" value="80" oninput="document.getElementById('master-val').textContent=this.value+'%'" id="slider-5-1">
      </div>
      <div>
        <div class="vt-flex vt-justify-between vt-items-center vt-mb-2">
          <label class="vt-label vt-flex vt-items-center vt-gap-2" for="slider-5-2">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" class="vt-w-4 vt-h-4 vt-text-foreground-muted" aria-hidden="true">
              <circle cx="9.49249" cy="17" r="4" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></circle><path d="M14.2425 3C14.2425 2.58579 13.9067 2.25 13.4925 2.25C13.0783 2.25 12.7425 2.58579 12.7425 3H13.4925H14.2425ZM16.6211 11.5356C16.3647 11.8608 16.4204 12.3324 16.7457 12.5889C17.0709 12.8454 17.5425 12.7897 17.799 12.4644L17.2101 12L16.6211 11.5356ZM13.4925 3H12.7425C12.7425 4.29862 13.4137 5.20585 14.1893 5.8847C14.5723 6.21986 14.9965 6.5139 15.3975 6.78012C15.8128 7.0558 16.1867 7.2914 16.5387 7.54556C17.2554 8.06308 17.6329 8.4914 17.7213 8.97169C17.8076 9.44028 17.66 10.2182 16.6211 11.5356L17.2101 12L17.799 12.4644C18.9287 11.0318 19.4007 9.80972 19.1965 8.70019C18.9945 7.60235 18.1715 6.87442 17.4168 6.32944C17.033 6.05235 16.6033 5.78013 16.2271 5.53042C15.8367 5.27126 15.4816 5.02232 15.1772 4.75593C14.5782 4.23165 14.2425 3.70138 14.2425 3H13.4925ZM13.4925 3H12.7425V17H13.4925H14.2425V3H13.4925Z" fill="currentColor"></path>
            </svg>
            Music
          </label>
          <span id="music-val" class="vt-text-sm vt-tabular-nums vt-text-foreground-muted">60%</span>
        </div>
        <input class="vt-slider" type="range" min="0" max="100" value="60" oninput="document.getElementById('music-val').textContent=this.value+'%'" id="slider-5-2">
      </div>
      <div>
        <div class="vt-flex vt-justify-between vt-items-center vt-mb-2">
          <label class="vt-label vt-flex vt-items-center vt-gap-2" for="slider-5-3">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" class="vt-w-4 vt-h-4 vt-text-foreground-muted" aria-hidden="true">
              <path d="M16 18C16 20.2091 14.2091 22 12 22C9.79086 22 8 20.2091 8 18" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path><path d="M4.43654 18H19.5625C20.2903 18 20.6542 18 20.8648 17.8951C21.274 17.6913 21.4929 17.2359 21.3964 16.789C21.3468 16.559 21.1194 16.2749 20.6648 15.7066L20.4951 15.4944C20.0392 14.9246 19.8113 14.6397 19.6184 14.3409C19.0187 13.4119 18.6477 12.354 18.5356 11.254C18.4995 10.9002 18.4995 10.5353 18.4995 9.8056V8.5C18.4995 8.03572 18.4995 7.80358 18.4867 7.60758C18.2898 4.60304 15.8965 2.20977 12.892 2.01285C12.696 2 12.4638 2 11.9995 2C11.5353 2 11.3031 2 11.1071 2.01285C8.10258 2.20977 5.70931 4.60304 5.51239 7.60758C5.49954 7.80358 5.49954 8.03572 5.49954 8.5V9.8056C5.49954 10.5353 5.49954 10.9002 5.46349 11.254C5.35143 12.354 4.98035 13.4119 4.38067 14.3409C4.18779 14.6397 3.95985 14.9246 3.50401 15.4944L3.33427 15.7066C2.87964 16.2749 2.65233 16.559 2.60268 16.789C2.50621 17.2359 2.72509 17.6913 3.13431 17.8951C3.3449 18 3.70878 18 4.43654 18Z" stroke="currentColor" stroke-width="1.5"></path>
            </svg>
            Alerts
          </label>
          <span id="alert-val" class="vt-text-sm vt-tabular-nums vt-text-foreground-muted">45%</span>
        </div>
        <input class="vt-slider" type="range" min="0" max="100" value="45" oninput="document.getElementById('alert-val').textContent=this.value+'%'" id="slider-5-3">
      </div>
    </div>
  </div>
</div>

Guidelines

75%
Do Use a slider for ranges where feel matters more than precision.
$1,247
Don't Don't use a slider when users need to enter an exact value.

API Reference

Class Type Description
.vt-slider Base Native range input — styled via CSS for track and thumb
min/max Attribute HTML attributes defining the slider range boundaries
step Attribute Defines discrete step increments for the slider value
value Attribute Sets the initial slider value
disabled State HTML attribute — reduced opacity, no interaction

Accessibility

Feature Details
Role Use input.vt-slider[type="range"] or role="slider" for the slider handle
Label Provide visible label linked via for/id or aria-label
Keyboard Arrow keys adjust value by step, Home/End jump to min/max
Value aria-valuenow, aria-valuemin, aria-valuemax describe the current state
Text Use aria-valuetext for human-readable values, e.g. "50 percent"