Forms & inputs
Layout
Knob
A rotary control that sets a number within a fixed arc. Use it for bounded values, such as a volume or a level.
Validating a form? vael-form wires this up with a schemaInstall
import { Knob } from 'vael-ui'Playground
md
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Knob } from 'vael-ui'
const value = ref(0)
</script>
<template>
<Knob aria-label="Volume" v-model="value" />
</template>Motion New
Knob: its appearance, states and the fill's timing.
<Knob
:motion="{ states: { disabled: { root: { scale: 1.04 } } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | roottrackfillindicator | Sets 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. |
states | disabledfocusactive | Sets 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) => animation | Animates 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 | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns 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.
| Key | Action |
|---|---|
| ArrowRightArrowUp | Increases the value by one step. |
| ArrowLeftArrowDown | Decreases the value by one step. |
| PageUp | Increases the value by ten steps. |
| PageDown | Decreases the value by ten steps. |
| Home | Sets the value to min. |
| End | Sets the value to max. |
- The dial has
role="slider"witharia-valuenow,aria-valueminandaria-valuemax, andaria-invalidwhen invalid. PassvalueTextto setaria-valuetext. - Inside a
Field, the label names the dial. Without one, passaria-label: it moves from the wrapper to the dial. - Pressing the dial focuses it.
- The arrow keys don’t swap right to left.