vael-ui v0.5.7

Actions

Layout

Dial

A wheel you turn to change a number, with no end stops unless you set min or max. Use it for open-ended values and fine adjustments.

Install

import { Dial } from 'vael-ui'

Playground

0

Placement, behaviour and animation

Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Dial } from 'vael-ui'

const value = ref(0)
</script>

<template>
  <Dial aria-label="Value" v-model="value" />
</template>

Props

NameTypeDefaultDescription
minnumberLowest allowed value. Omit for no lower bound.
maxnumberHighest allowed value. Omit for no upper bound; the progress ring shows only when both are set.
stepnumber1Value change per arrow key or per degreesPerStep of rotation. Page Up/Down move ten steps.
degreesPerStepnumberDegrees of pointer rotation per step of value change. Unset, uses 15.
showValuebooleantrueShows the current value in the center of the dial.
size'sm' | 'md' | 'lg''md'Control size.
disabledbooleanfalseDisables the dial and blocks interaction.
invalidbooleanfalseShows the invalid state. A surrounding Field in error sets it too.
namestringNative name for form submission, via a hidden input.
valueText((value: number) => string)Drives aria-valuetext, e.g. (v) => \${v} dB\`` for a gain dial.
uiPartial<Record<'root' | 'dial' | 'track' | 'fill' | 'ticks' | 'face', UiPartValue>>Class and style overrides for each part.
motionDialMotionHow it moves: its appearance ({ initial: { root: { opacity: 0, scale: 0.9 } } }) and its states, like active while you turn it ({ states: { active: { face: { scale: '0.97' } } } }). false turns its own animation off.
modelValuenumber0Current value.

Events

NameTypeDescription
update:modelValue(value: number)Fires when modelValue changes (v-model).
change(value: number)Fires with the final value when you release the dial or press a key, like a native range input's change. v-model updates on every move.

Slots

No slots.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
dialElHTMLElement | nullFocusable dial element (role="slider").
ticksElSVGGElement | nullSVG group holding the tick marks.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

Dial: its appearance, states and the fill's timing.

<Dial
  :motion="{ states: { disabled: { root: { scale: 1.04 } } } }"
/>
NameTypeDescription
initialexitroottrackfillfaceticksSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
statesdisabledfocusactiveSets values per part that hold while a state is on. An array is a set of keyframes that plays once as the state turns on, such as a shake on invalid.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

Follows the Slider pattern from the WAI-ARIA Authoring Practices Guide.

KeyAction
ArrowRightArrowUpIncreases the value by one step.
ArrowLeftArrowDownDecreases the value by one step.
PageUpPageDownChanges the value by ten steps.
HomeEndSets the value to min or max, when they are set.
  • Renders role="slider" with aria-valuenow, plus aria-valuemin and aria-valuemax when min and max are set.
  • Without min and max, aria-valuetext reads the value, so screen readers don’t assume 0 to 100. valueText replaces it.
  • It needs a name: wrap it in a Field, or pass aria-label or aria-labelledby. They land on the focusable dial.
  • Disabled, it sets aria-disabled and leaves the Tab order. Invalid, it sets aria-invalid.