Form workflow example

Validate a small local workflow.

The form adapter owns draft state and feedback; the supplied submit callback keeps the result in memory.

Complete React client module · MIT · Next.js and Vite

Interactive example

Validate a small local workflow

The form adapter owns draft state and feedback; the supplied submit callback keeps the result in memory.

Loads this example when you need it.

Keyboard

  • Submit focuses the first invalid named field.
  • Native input editing and clipboard commands remain available.

States covered

  • Pristine
  • Dirty
  • Invalid
  • Saved

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-basic-form.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import {useState} from 'react';
import {Button,Field,Form,FormErrorSummary,Input,useForm} from '@bld8/ui';
import '@bld8/ui/styles.css';
export default function FormExample(){const [result,setResult]=useState('');const form=useForm({initialValues:{name:''},validate:values=>({name:values.name.trim()?undefined:'Enter an example project name.'}),onSubmit:async(values,{signal})=>{if(signal.aborted)return;setResult(values.name);}});return <Form form={form}><FormErrorSummary error={form.error} errors={form.errors}/><Field label="Example project name" error={form.errors.name}><Input name="name" value={form.values.name} onChange={event=>form.setField('name',event.target.value)}/></Field><Button type="submit" loading={form.pending}>Save local form example</Button><p role="status">{result?'Local result: '+result:''}</p></Form>;}