GhostSlider reference
Package: @ghostvue/vue. Status: experimental (stability policy).
Headless range input with APG slider semantics, optional two-thumb range mode, stepped keyboard interaction, and hidden form inputs. GhostSlider is the unstyled root; useGhostSlider owns the model.
Generated from the component manifest. Edit the manifest or Vue source, then rebuild the docs.
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
defaultValue | GhostSliderValue | — | No | Uncontrolled seed and form-reset baseline. |
disabled | boolean | false | No | Non-operable; hidden inputs not submitted. |
form | string | — | No | External form association. |
max | number | 100 | No | Upper bound. |
messages | GhostSliderMessages | — | No | Overridable range-thumb naming strings (`minimum`, `maximum`) and `aria-label` formatters (`formatMinimumLabel`, `formatMaximumLabel`). |
min | number | 0 | No | Lower bound. |
modelValue | GhostSliderValue | — | No | Controlled value; tuple when `range` is true. |
name | string | — | No | Primary hidden field name. |
nameMax | string | — | No | High thumb name when `range` is true. |
orientation | 'horizontal' | 'vertical' | "horizontal" | No | Axis and keyboard mapping. |
range | boolean | false | No | Two-thumb interval mode. |
step | number | 1 | No | Snap increment. |
valueText | string | — | No | `aria-valuetext` for single-thumb mode. |
Emits
None declared.
Models
| Prop | Event | Type | Description |
|---|---|---|---|
modelValue | update:modelValue | GhostSliderValue | v-model binding for `modelValue`. |
Slots
| Name | Description |
|---|---|
default | Optional inner content. Prefer aria-labelledby or an external label. |
Slot props: default
None declared.
Exposed members
| Name | Type | Description |
|---|---|---|
blur | () => void | Exposed method `blur`. |
element | HTMLElement | null | Root element after mount; null before mount. |
focus | (options?: FocusOptions) => void | Exposed method `focus`. |
value | GhostSliderValue | Exposed property `value`. |
Parts and data attributes
| Attribute | Value | Description |
|---|---|---|
data-part | root | Track container; native attributes fall through here. |
data-part | track | Full axis span; pointer press moves the nearest thumb. |
data-part | range | Selected interval or fill from min to the value. |
data-part | thumb | role=slider handle; data-thumb-index 0 or 1 in range mode. |
data-orientation | horizontal, vertical | Resolved orientation on the root. Always present. |
CSS variables
None declared.
Accessibility
Role: slider. APG pattern: https://www.w3.org/WAI/ARIA/apg/patterns/slider/.
Required ARIA attributes: aria-valuemin, aria-valuemax, aria-valuenow.
Keyboard
Verification
Each category is reviewed separately. Automated keyboard and axe results do not attest manual or assistive-technology review.
| Category | Status | Evidence |
|---|---|---|
| Automated keyboard | Passed | Every declared key maps to a Chromium browser test that CI runs and requires to pass on every commit. |
| Manual interaction | Not reviewed | No review recorded. |
| Assistive technology | Not reviewed | No review recorded. |
Examples
slider/basic
Headless numeric slider with stepped values.
35 credits
<script setup lang="ts">
import { ref } from 'vue'
import { GhostSlider } from '@ghostvue/vue'
const amount = ref(35)
</script>
<template>
<GhostSlider
v-model="amount"
aria-label="Donation amount slider"
:min="0"
:max="100"
:step="5"
/>
<p>{{ amount }} credits</p>
</template>
<style scoped>
/*
* Headless path ships no visuals; this is consumer CSS for the sample. The
* library positions the rail, range, and thumbs; the sample gives the root a
* box and paints the parts. Parts render inside GhostSlider, so scoped CSS
* needs :deep(). System colors follow light and dark mode without a theme.
*/
.ghost-slider {
block-size: 1.5rem;
inline-size: min(100%, 20rem);
position: relative;
}
.ghost-slider :deep([data-part='rail']) {
background: GrayText;
border-radius: 999px;
}
.ghost-slider :deep([data-part='range']) {
background: Highlight;
border-radius: 999px;
}
.ghost-slider :deep([data-part='thumb']) {
background: Canvas;
block-size: 1.125rem;
border: 2px solid Highlight;
border-radius: 50%;
box-sizing: border-box;
inline-size: 1.125rem;
}
</style>
slider/range
Two-thumb interval selection for tables.
From 25 to 75
<script setup lang="ts">
import { ref } from 'vue'
import { GhostSlider } from '@ghostvue/vue'
const bounds = ref<readonly [number, number]>([25, 75])
</script>
<template>
<GhostSlider
v-model="bounds"
range
aria-label="Score interval"
:min="0"
:max="100"
:step="5"
/>
<p>From {{ bounds[0] }} to {{ bounds[1] }}</p>
</template>
<style scoped>
/*
* Headless path ships no visuals; this is consumer CSS for the sample. The
* library positions the rail, range, and thumbs; the sample gives the root a
* box and paints the parts. Parts render inside GhostSlider, so scoped CSS
* needs :deep(). System colors follow light and dark mode without a theme.
*/
.ghost-slider {
block-size: 1.5rem;
inline-size: min(100%, 20rem);
position: relative;
}
.ghost-slider :deep([data-part='rail']) {
background: GrayText;
border-radius: 999px;
}
.ghost-slider :deep([data-part='range']) {
background: Highlight;
border-radius: 999px;
}
.ghost-slider :deep([data-part='thumb']) {
background: Canvas;
block-size: 1.125rem;
border: 2px solid Highlight;
border-radius: 50%;
box-sizing: border-box;
inline-size: 1.125rem;
}
</style>
slider/vertical
Themed vertical orientation and tokens.
Gain 60%
<script setup lang="ts">
import { ref } from 'vue'
import { GhostSlider } from '@ghostvue/themes'
const level = ref(60)
</script>
<template>
<GhostSlider
v-model="level"
orientation="vertical"
aria-label="Channel gain"
:min="0"
:max="100"
:value-text="`${level} percent`"
/>
<!-- Fixed line-height avoids subpixel line-box drift in visual snapshots. -->
<p style="margin: 0; line-height: var(--ghost-font-line-body, 1.25rem)">
Gain {{ level }}%
</p>
</template>
slider/value-text
Named slider with aria-valuetext alongside the numeric value.
<script setup lang="ts">
import { ref } from 'vue'
import { GhostSlider } from '@ghostvue/vue'
const score = ref(72)
</script>
<template>
<GhostSlider
v-model="score"
aria-label="Match quality"
:min="0"
:max="100"
value-text="72 percent match"
/>
</template>
<style scoped>
/*
* Headless path ships no visuals; this is consumer CSS for the sample. The
* library positions the rail, range, and thumbs; the sample gives the root a
* box and paints the parts. Parts render inside GhostSlider, so scoped CSS
* needs :deep(). System colors follow light and dark mode without a theme.
*/
.ghost-slider {
block-size: 1.5rem;
inline-size: min(100%, 20rem);
position: relative;
}
.ghost-slider :deep([data-part='rail']) {
background: GrayText;
border-radius: 999px;
}
.ghost-slider :deep([data-part='range']) {
background: Highlight;
border-radius: 999px;
}
.ghost-slider :deep([data-part='thumb']) {
background: Canvas;
block-size: 1.125rem;
border: 2px solid Highlight;
border-radius: 50%;
box-sizing: border-box;
inline-size: 1.125rem;
}
</style>