0
Fork 0
mirror of https://github.com/TanStack/form.git synced 2026-11-18 07:36:42 +00:00
form/docs/framework/angular/quick-start.md
Corbin Crutchley f584b074a7
Preact integration (#2148)
* Add preact integration for tanstack form

* ci: apply automated fixes and generate docs

* Remove accidental reference to compat

* Remove use clien

* onInput for test parity

* Add docs

* Remove useUUid

* ci: apply automated fixes and generate docs

* Add example

* Fix

* chore: remove CHANGELOG

* chore: update version

* ci: apply automated fixes and generate docs

* Create compat bridge for outdated form-core store

* Apply suggestion from @JoviDeCroock

* chore: add changeset

* chore: update version number

---------

Co-authored-by: Jovi De Croock <decroockjovi@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-05-08 13:32:14 -04:00

1.5 KiB

id title
quick-start 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.

import { Component } from '@angular/core'
import { bootstrapApplication } from '@angular/platform-browser'
import { TanStackField, injectForm } from '@tanstack/angular-form'

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [TanStackField],
  template: `
    <form (submit)="handleSubmit($event)">
      <div>
        <ng-container [tanstackField]="form" name="fullName" #fullName="field">
          <label [for]="fullName.api.name">First Name:</label>
          <input
            [name]="fullName.api.name"
            [value]="fullName.api.state.value"
            (blur)="fullName.api.handleBlur()"
            (input)="fullName.api.handleChange($any($event).target.value)"
          />
        </ng-container>
      </div>
      <button type="submit">Submit</button>
    </form>
  `,
})
export class AppComponent {
  form = injectForm({
    defaultValues: {
      fullName: '',
    },
    onSubmit({ value }) {
      // Do something with form data
      console.log(value)
    },
  })

  handleSubmit(event: SubmitEvent) {
    event.preventDefault()
    event.stopPropagation()
    this.form.handleSubmit()
  }
}

bootstrapApplication(AppComponent).catch((err) => console.error(err))

From here, you'll be ready to explore all of the other features of TanStack Form!