Forms & inputs
Layout
Editable
Text that turns into an input when you click it, and saves on Enter or blur. Use it to rename something in place.
Validating a form? vael-form wires this up with a schemaInstall
import { Editable } from 'vael-ui'Playground
click
both
md
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Editable } from 'vael-ui'
const value = ref('')
</script>
<template>
<Editable placeholder="Type here…" v-model="value" />
</template>Motion New
Editable: its appearance and states.
<Editable
:motion="{ states: { editing: { root: { scale: 1.04 } } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | rootprevieweditinputactions | 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 | editingdisabledfocus | 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
| Key | Action |
|---|---|
| Enter | Opens the input from the preview. |
| Space | Opens the input from the preview when activationMode is 'click'. |
| Enter | Saves the edit when submitMode is 'enter' or 'both'. |
| Escape | Drops the edit and closes the input. |
| Tab | Saves or drops the edit as focus leaves, following submitMode. |
- The preview is a native
button. Witharia-labeloraria-labelledbythe label is its name and its text its description ("Notes, button, Pressure low"); without one, its text is its name. - Opening moves focus into the input and selects its text when
selectOnFocusis on. Closing with Enter or Escape moves focus back to the preview; leaving with Tab keeps focus where it went. - In a Textarea passed to
#edit, Enter adds a new line and Cmd or Ctrl with Enter saves. Focus moving to#actionsor a picker panel inside the edit does not count as leaving. aria-labelandaria-labelledbyname the preview and the built-in input; other attributes go to the wrapper. A control you pass in#editneeds its own label.