Skip to content

Form

Submit form values and check their validity.

Demos

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy Form.vue and index.ts into app/components/ui/form/.

API

Props

PropTypeDefaultDescription
idstring—Form id.
actionstring—Native form action.
method"get" | "post" | "dialog""post"Native form method.
autocomplete"on" | "off"—Native autocomplete setting.
novalidatebooleanfalseDisables native browser validation.
preventDefaultbooleantruePrevent native navigation on submit.
errorsFormErrors—Server-side errors read by child fields using matching names.
uiFormUi—Classes for the form element.

Slots

SlotScoped propsDescription
defaultstate, submitted, validForm contents and current submit state.

Events

EventPayloadDescription
submitFormSubmitDetailsFired on native submit. Includes formData, valid, and cancel().
form-submit(values, details)Fired with a values object converted from FormData, plus submit details.