form-patterns

Build DaisyUI v5 forms in Svelte with validation and error handling.

6|Updated Aug 8, 2023
One-click install
npx skills add https://github.com/spences10/devhub-crm --skill form-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: form-patterns
Source: https://github.com/spences10/devhub-crm/tree/main/.claude/skills/form-patterns
Command: npx skills add https://github.com/spences10/devhub-crm --skill form-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill provides a clear and consistent set of patterns for building forms using DaisyUI v5, addressing the significant changes from v4. It ensures forms are well-structured, accessible, visually appealing, and integrate seamlessly with SvelteKit's remote function error handling, saving development time and improving user experience.

Core Features & Use Cases

  • DaisyUI v5 Structure: Guides on using the new fieldset/fieldset-legend and <label class="input"> patterns for inputs, ensuring correct styling and accessibility.
  • Automatic Validation UI: Leverages the validator class to provide instant visual feedback for input validation states, improving user guidance.
  • Consistent Spacing & Layout: Recommends space-y-4 for forms and w-full for inputs to maintain a uniform and responsive design across your application.
  • Integrated Error Handling: Shows how to display server-side errors from SvelteKit remote functions directly within the form, providing immediate and relevant feedback to users.
  • Use Case: Create a user registration form that includes fields for name, email, and password. This Skill provides the exact DaisyUI v5 classes and structure to build this form, ensuring it looks professional, provides clear validation feedback, and handles errors gracefully.

Quick Start

Wrap form fields in <fieldset class="fieldset"> with a <legend class="fieldset-legend">. For inputs, use <label class="input w-full"> as a wrapper, containing <input class="grow">. Add the validator class to the <label> for automatic validation styling. For selects and textareas, apply select w-full or textarea w-full directly to the element. Display server errors using {#if my_form.error}.

Frequently Asked Questions about form-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build accessible forms with DaisyUI v5?

DaisyUI v5 forms use fieldset with fieldset-legend wrappers and label class="input" containers for inputs, ensuring semantic structure and accessibility. Combine with the validator class for automatic validation styling and w-full for responsive sizing across your form fields.

How do I add validation feedback to form inputs in SvelteKit?

Apply the validator class to label or input wrappers to enable instant visual feedback. Pair with SvelteKit remote function error handling to display server-side errors directly within the form, providing immediate user guidance on validation failures.

What's the correct structure for DaisyUI v5 form fields?

Wrap fields in fieldset class="fieldset" with a legend class="fieldset-legend". For inputs, use label class="input w-full" containing input class="grow". For selects and textareas, apply select w-full or textarea w-full directly, maintaining consistent spacing with space-y-4 between fields.

Can I use DaisyUI v5 forms with the Tailwind forms plugin?

DaisyUI v5 forms work with direct class usage on controls. The Skill provides compatibility guidance for using Tailwind forms plugin alongside DaisyUI patterns, though the native DaisyUI structure is recommended for full consistency and validator-driven styling.

Do I need to style form inputs separately with Tailwind CSS?

No. DaisyUI v5 handles styling through semantic classes like input, select, and textarea with w-full for responsive width. The validator class automates validation state styling, eliminating the need for custom Tailwind utility chains on individual controls.

How do I display server errors from SvelteKit in forms?

Use conditional rendering like {#if my_form.error} to display server-side errors directly within the form structure. DaisyUI v5 patterns integrate seamlessly with SvelteKit's remote function error handling for immediate, contextual error feedback.