UIPackage
Menu

Framework

Change language

Boilerplate repo

Form

formui

Zod-first form block built on TanStack Vue Form. Wires field labels, descriptions, error messages, and validation together; bind a field once and the rest is automatic.

Also available for React ->

Installation

$npx shadcn-vue@latest add https://uipkge.dev/r/vue/form.json
Named registry:npx shadcn-vue@latest add @uipkge/formInstalls to:app/components/ui/form/

Examples

Loading interactive previews…

Props

NameType / ValuesDefaultRequired
formTanstackFormApirequired
classHTMLAttributes['class']optional

Schema

Type aliases from this item's source — use them to shape the data you pass in.

FieldMeta
interface FieldMeta {
  errors: Array<unknown>
  errorMap?: Record<string, Array<unknown> | undefined>
  isDirty: boolean
  isTouched: boolean
  isValid: boolean
}
FieldApi
interface FieldApi {
  name: string
  state: {
    value: unknown
    meta: FieldMeta
  }
  store: {
    subscribe: (cb: () => void) => (() => void) | { unsubscribe: () => void }
  }
  handleChange: (v: unknown) => void
  handleBlur: () => void
}
FormFieldContext
interface FormFieldContext {
  name: string
  error: ComputedRef<string | undefined>
  valid: ComputedRef<boolean>
  isDirty: ComputedRef<boolean>
  isTouched: ComputedRef<boolean>
}
TanstackFormApi
interface TanstackFormApi {
  Field: unknown
  handleSubmit: () => void | Promise<void>
}

Files installed (15)

  • app/components/ui/form/Form.vue0.6 kB
    <script lang="ts" setup>
    import type { HTMLAttributes } from 'vue'
    import { provide } from 'vue'
    import { cn } from '@/lib/utils'
    import { FORM_INSTANCE_INJECTION_KEY, type TanstackFormApi } from './injectionKeys'
    
    const props = defineProps<{
      form: TanstackFormApi
      class?: HTMLAttributes['class']
    }>()
    
    provide(FORM_INSTANCE_INJECTION_KEY, props.form)
    
    function onSubmit(e: Event) {
      e.preventDefault()
      e.stopPropagation()
      void props.form.handleSubmit()
    }
    </script>
    
    <template>
      <form data-uipkge data-slot="form" :class="cn(props.class)" @submit="onSubmit">
        <slot />
      </form>
    </template>
    
  • app/components/ui/form/FormActions.vue0.7 kB
  • app/components/ui/form/FormControl.vue0.4 kB
  • app/components/ui/form/FormDescription.vue0.5 kB
  • app/components/ui/form/FormField.vue0.9 kB
  • app/components/ui/form/FormFieldInner.vue2.6 kB
  • app/components/ui/form/FormItem.vue2.3 kB
  • app/components/ui/form/FormLabel.vue0.6 kB
  • app/components/ui/form/FormMessage.vue0.5 kB
  • app/components/ui/form/FormSection.vue0.9 kB
  • app/components/ui/form/FormStatus.vue1.2 kB
  • app/components/ui/form/index.ts0.8 kB
  • app/components/ui/form/injectionKeys.ts0.6 kB
  • app/components/ui/form/types.ts0.1 kB
  • app/components/ui/form/useFormField.ts0.7 kB

Raw manifest:https://uipkge.dev/r/vue/form.json