AkiForm Builder
AkiformBuilder provides a schema-driven approach to form creation, automatically rendering fields based on a declarative configuration.
Installation
pnpm add @akinon/akiform-builderBasic Usage
import { AkiformBuilder, field, type FormField } from '@akinon/akiform-builder';
import { akival } from '@akinon/akival';
interface UserForm {
name: string;
email: string;
role: string;
}
const formFields: FormField<UserForm>[] = [
field<UserForm>()
.key('name')
.type('text')
.label('Name')
.placeholder('Enter name')
.validation(akival.string().required())
.build(),
field<UserForm>()
.key('email')
.type('text')
.label('Email')
.placeholder('Enter email')
.validation(akival.string().email().required())
.build(),
field<UserForm>()
.key('role')
.type('select')
.label('Role')
.placeholder('Select role')
.options([
{ label: 'Admin', value: 'admin' },
{ label: 'User', value: 'user' },
{ label: 'Guest', value: 'guest' }
])
.build()
];
export const UserFormPage = () => {
const handleSubmit = (values: UserForm) => {
console.log('Form values:', values);
};
return (
<AkiformBuilder
fields={formFields}
layout="vertical"
onSubmit={handleSubmit}
/>
);
};Props
Prop
Type
Description
Field Builder API
Field Types
Text
Number
Select
Date
Date with Time
Checkbox
Textarea
Custom
Layout Fields
Section
Row and Column
Field Array
Conditional Fields
Controlled Mode
API Field Errors
Complete Example
Best Practices
Related
Last updated
Was this helpful?

