Files
form/docs/framework/vue/quick-start.md
Robert Soriano 6935b330fa feat(vue): field is now destructured from Field. TypeScript types are much more strict now
* fix(vue): Subscribe component default scoped slot types

* fix(vue): Field component default scoped slot value types

* example type fixes

* remove test log

* docs(vue): Field component slot fix

* refactor(vue): remove unused children property type from field component

* chore: fix formatting

---------

Co-authored-by: Corbin Crutchley <git@crutchcorn.dev>
2023-09-08 14:41:54 -07:00

47 lines
1.0 KiB
Markdown

---
id: quick-start
title: Quick Start
---
The bare minimum to get started with TanStack Form is to create a form and add a field. Keep in mind that this example does not include any validation or error handling... yet.
```vue
<!-- App.vue -->
<script setup>
import { useForm } from '@tanstack/vue-form'
const form = useForm({
// Memoize your default values to prevent re-renders
defaultValues: {
fullName: '',
},
onSubmit: async (values) => {
// Do something with form data
console.log(values)
},
})
form.provideFormContext()
</script>
<template>
<div>
<div>
<form.Field name="fullName">
<template v-slot="{ field }">
<input
:name="field.name"
:value="field.state.value"
:onBlur="field.handleBlur"
:onChange="(e) => field.handleChange(e.target.value)"
/>
</template>
</form.Field>
</div>
<button type="submit">Submit</button>
</div>
</template>
```
From here, you'll be ready to explore all of the other features of TanStack Form!