一键导入
create-modus-form-component
// Scaffold form components with proper Modus input integration, event handling, validation, and checkbox bug handling
// Scaffold form components with proper Modus input integration, event handling, validation, and checkbox bug handling
Scaffold a new Modus wrapper component following established SolidJS patterns with proper TypeScript interfaces, event handling, and cleanup
Debug and fix common event handling problems with Modus web components
Apply the critical checkbox value inversion workaround when working with ModusCheckbox components
Create Modus modals using the callback ref pattern for programmatic control
Help with correct Modus icon usage patterns including naming conventions, sizing, and accessibility
Build production-grade frontend interfaces using the Modus 2.0 Design System with Tailwind CSS. Use this skill when the user asks to build web components, pages, dashboards, or application screens. Enforces the 9-color semantic system, Modus Web Components, Modus Icons, and design system compliance. Framework-agnostic (works with SolidJS, React, Angular, or any framework).
| name | create-modus-form-component |
| description | Scaffold form components with proper Modus input integration, event handling, validation, and checkbox bug handling |
Scaffold form components with proper Modus input integration, event handling, validation feedback, and checkbox bug handling in SolidJS.
Use this skill when:
Modus forms in SolidJS follow these patterns:
import { createSignal } from "solid-js";
import type { Component } from "solid-js";
import ModusTextInput from "./components/ModusTextInput";
import ModusCheckbox from "./components/ModusCheckbox";
import ModusButton from "./components/ModusButton";
import ModusInputFeedback from "./components/ModusInputFeedback";
import ModusInputLabel from "./components/ModusInputLabel";
interface FormData {
name: string;
email: string;
agreeToTerms: boolean;
}
const ContactForm: Component = () => {
const [formData, setFormData] = createSignal<FormData>({
name: "",
email: "",
agreeToTerms: false,
});
const [errors, setErrors] = createSignal<
Partial<Record<keyof FormData, string>>
>({});
const updateField = (field: keyof FormData, value: string | boolean) => {
setFormData((prev) => ({ ...prev, [field]: value }));
setErrors((prev) => {
if (prev[field]) {
return { ...prev, [field]: undefined };
}
return prev;
});
};
const validateForm = (): boolean => {
const data = formData();
const newErrors: Partial<Record<keyof FormData, string>> = {};
if (!data.name.trim()) {
newErrors.name = "Name is required";
}
if (!data.email.trim()) {
newErrors.email = "Email is required";
} else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data.email)) {
newErrors.email = "Please enter a valid email address";
}
if (!data.agreeToTerms) {
newErrors.agreeToTerms = "You must agree to the terms";
}
setErrors(newErrors);
return Object.keys(newErrors).length === 0;
};
const handleSubmit = () => {
if (validateForm()) {
console.log("Form submitted:", formData());
}
};
return (
<div class="max-w-md mx-auto p-6 bg-card border-default rounded-lg">
<div class="text-2xl font-bold mb-6 text-foreground">Contact Us</div>
<div class="space-y-4">
{/* Name Field */}
<div>
<ModusInputLabel label="Name" required size="md" />
<ModusTextInput
value={formData().name}
onInputChange={(event) => {
const value = (event.target as HTMLModusWcTextInputElement).value;
updateField("name", value);
}}
placeholder="Enter your name"
required
size="md"
/>
{errors().name && (
<ModusInputFeedback
message={errors().name}
type="error"
size="md"
/>
)}
</div>
{/* Email Field */}
<div>
<ModusInputLabel label="Email" required size="md" />
<ModusTextInput
type="email"
value={formData().email}
onInputChange={(event) => {
const value = (event.target as HTMLModusWcTextInputElement).value;
updateField("email", value);
}}
placeholder="Enter your email"
required
size="md"
/>
{errors().email && (
<ModusInputFeedback
message={errors().email}
type="error"
size="md"
/>
)}
</div>
{/* Checkbox Field */}
<div>
<ModusCheckbox
label="I agree to the terms and conditions"
value={formData().agreeToTerms}
onValueChange={(event) => {
// ✅ Checkbox value is already corrected (inverted) by wrapper
updateField("agreeToTerms", event.detail);
}}
required
size="md"
/>
{errors().agreeToTerms && (
<ModusInputFeedback
message={errors().agreeToTerms}
type="error"
size="md"
/>
)}
</div>
{/* Submit Button */}
<div class="flex gap-2 pt-4">
<ModusButton color="primary" variant="filled" onButtonClick={handleSubmit}>
Submit
</ModusButton>
<ModusButton
variant="borderless"
onButtonClick={() => {
setFormData({ name: "", email: "", agreeToTerms: false });
setErrors({});
}}
>
Reset
</ModusButton>
</div>
</div>
</div>
);
};
export default ContactForm;
const [formData, setFormData] = createSignal<FormData>({
name: "",
email: "",
agreeToTerms: false,
});
// ✅ CORRECT: Extract value from event target
onInputChange={(event) => {
const value = (event.target as HTMLModusWcTextInputElement).value;
updateField("fieldName", value);
}}
// ✅ CORRECT: Use event.detail (already corrected by wrapper)
onValueChange={(event) => {
updateField("checkboxField", event.detail);
}}
{errors().fieldName && (
<ModusInputFeedback
message={errors().fieldName}
type="error"
size="md"
/>
)}
Use class not className:
<div class="max-w-md mx-auto p-6 bg-card border-default rounded-lg">
event.target.value for inputs, not event.detailsrc/components/ModusTextInput.tsx - Text input componentsrc/components/ModusCheckbox.tsx - Checkbox component (handles bug)src/components/ModusTextarea.tsx - Textarea componentsrc/components/ModusInputFeedback.tsx - Validation feedbacksrc/components/ModusInputLabel.tsx - Input labels