TailwindForm
Like TailwindCSS, but for form markup.
className your way to forms!
React Server ComponentsZero StatePlain HTMLNo Opinions
<Form className="form-field-email:email:required -field-password:password:required-submit-Log_In" />renders
Syntax Reference
<Form className="form[-id-X]-field-{name}[:{type}][:{modifier}]...-submit[-{label}]" />field-nameText field
field-email:emailEmail type
:requiredRequired
:options-a,b,cSelect/Radio
submit-Sign_UpSubmit button
form-id-loginID prefix
Field Types
| Type | Output |
|---|---|
text (default) | <input type="text"> |
email | <input type="email"> |
password | <input type="password"> |
textarea | <textarea> |
select | <select> |
radio | <input type="radio"> group |
checkbox | <input type="checkbox"> |
number, date, file, etc. | Corresponding HTML input types |
Live Examples
Real forms generated from className
Multiple Forms
Use form-id-X to prefix field IDs
How to Use
// With server actionimport { Form } from '@tailwind-stack/form'<Form className="form-field-name-field-email:email-submit" action={myServerAction}/>// Or REST<Form className="form-field-title-field-body:textarea-submit" action="/api/posts" method="POST"/>// Add extra content via children<Form className="form-field-name" action={action}> <p>Custom content here</p> <button type="submit">Go</button></Form>