Forms
Type-safe forms with Zod validation and field components that integrate with the SiteKnock UI kit.
Overview
SiteKnock's form components give you accessible, validated form fields that pair the UI kit's inputs with Zod schemas for type-safe validation and clear error display.
Form fields
The FormField component connects a label, an input, and validation error display:
import { FormField } from "@siteknock/forms/form-field"
import { Input } from "@siteknock/ui"
<FormField label="Email" error={errors.email}>
<Input type="email" data-testid="email" />
</FormField>
Validation with Zod
Define a schema once and get type-safe validation and inferred types:
import { z } from "zod"
const schema = z.object({
email: z.string().email(),
password: z.string().min(8),
})
Common patterns
Auth forms
Sign-in and sign-up forms combine form fields, UI inputs, and Zod validation.
Settings forms
Pair with unsaved-changes tracking so users don't lose edits.
Filters
Lightweight forms for filtering data tables.
Building a custom form
- Define a Zod schema for validation.
- Use the form field components with the UI kit's inputs.
- Add
data-testidto every interactive element. - Use i18n keys for labels, placeholders, and error messages.
Next steps
Was this page helpful?