form-patterns
DaisyUI v5 form patterns. Use for inputs, selects, textareas, validation, and form structure with fieldset/legend.
When & Why to Use This Skill
This Claude skill provides standardized DaisyUI v5 form patterns, enabling developers to quickly implement accessible and validated web forms. It focuses on modern fieldset/legend structures, automatic validation UI, and consistent layout practices for Svelte and Tailwind CSS environments, ensuring code follows the latest framework specifications.
Use Cases
- Rapidly generating accessible form structures using the latest DaisyUI v5 fieldset and legend patterns instead of legacy form-control classes.
- Implementing robust client-side validation UI by applying the 'validator' class to input wrappers for instant user feedback.
- Standardizing form layouts across a project using consistent spacing (space-y-4) and modern input/select component wrappers.
- Migrating legacy DaisyUI form code to the more semantic and streamlined v5 architecture to ensure long-term maintainability.
| name | form-patterns |
|---|---|
| description | DaisyUI v5 form patterns. Use for inputs, selects, textareas, validation, and form structure with fieldset/legend. |
Form Patterns
Quick Start
<form {...my_form} class="space-y-4">
<fieldset class="fieldset">
<legend class="fieldset-legend">Name</legend>
<label class="validator input w-full">
<input
type="text"
name="name"
placeholder="Your name"
class="grow"
required
/>
</label>
</fieldset>
{#if my_form.error}
<div class="alert alert-error">{my_form.error}</div>
{/if}
<button class="btn btn-block btn-primary" type="submit"
>Submit</button
>
</form>
Core Principles
- v5 structure: Use
fieldset/fieldset-legend(NOT oldform-control/label-text) - Input wrapper:
<label class="input w-full">contains<input class="grow"> - Validation: Add
validatorclass to label for automatic validation UI - Selects/textareas: Apply classes directly (e.g.,
select w-full) - no wrapper - Error handling: Remote functions provide
.errorproperty automatically - Spacing: Use
space-y-4on forms for consistent spacing
Reference Files
- forms-guide.md - Complete DaisyUI v5 form patterns and examples