vael-ui v0.5.7

Forms & inputs

Layout

Input

A single-line text field with sizes, states, and start and end slots for icons or buttons. Use it for names, emails, search and other short text.

Validating a form? vael-form wires this up with a schema

Install

import { Input } from 'vael-ui'

Playground

Placement, behaviour and animation

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

const value = ref('')
</script>

<template>
  <Input placeholder="Type here…" v-model="value" />
</template>

Props

NameTypeDefaultDescription
typestring'text'Native input type.
size'sm' | 'md' | 'lg''md'Control size.
disabledbooleanfalseDisables the input and blocks interaction. A disabled parent Field also disables it.
readonlybooleanfalseMakes the value read-only while keeping it focusable and selectable.
invalidbooleanfalseStandalone override; ORed with the nearest Field's error state.
placeholderstringText shown while the input is empty.
clearablebooleanfalseShows a button that empties the input while it has text.
loadingbooleanfalseShows a spinner at the end while something loads for it, such as search results.
animatedbooleanfalseCrossfades a placeholder or value that changes on its own, like AnimatedText. What you type never animates.
uiPartial<Record<'root' | 'input' | 'start' | 'end' | 'clear', UiPartValue>>Class and style overrides for each part.
motionInputMotionAnimates its states, like a shake when it turns invalid: { states: { invalid: { root: { x: [0, -6, 6, -3, 0] } } } }.
modelValuestring''Input value. Supports the .trim and .lazy modifiers.

Events

NameTypeDescription
clear()Fires when the clear button empties the input.
update:modelValue(value: string)Fires when modelValue changes (v-model).

Slots

NameTypeDescription
startanyInline leading content, such as an icon, a Kbd hint or a copy Button.
endanyInline trailing content.
display{ value: string; placeholder: string; focused: boolean; }Draws the text yourself, over the input's own text box and following its scroll, for a fancy input: characters that animate in, gradients, highlighted tokens. The input underneath keeps the caret, selection and screen reader text; its own text is hidden. Give an element pointer-events: auto to let it take hover, say for a popover on a mention.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element (the frame around the input).
inputElHTMLInputElement | nullNative <input> element.

Motion New

Input's motion: values or hooks for its parts (InputPart), its states (invalid, disabled, focus). false turns it off.

<Input
  :motion="{ states: { invalid: { root: { scale: 1.04 } } } }"
/>
NameTypeDescription
initialexitrootinputstartendSets 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.
statesinvaliddisabledfocusSets 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

It has no keyboard interaction of its own.

  • Renders a native <input> and adds no keys of its own.
  • Inside a Field, the label names the input. aria-describedby lists your own ids first, then the Field’s description and error.
  • Outside a Field, give it an aria-label, which goes to the input. It sets aria-invalid when invalid and aria-required when the Field is required.
  • With clearable, a clear button named “Clear” shows while there’s text. It is a Tab stop, and clearing puts focus back in the input. The #display slot is aria-hidden; screen readers read the input underneath.