Text Field
TextField is a reusable input component for Shaddy Form with support for icons, actions, and loading state.
⚠️ This content is not available in your language yet.
TextField
is a reusable input component for Shaddy Form. It supports labels, required state, icons, loading indicators, custom actions, and more. Use it inside a Shaddy Form to collect user input with validation.
Installation
pnpm dlx shadcn@latest add https://shaddy-docs.vercel.app/r/text-field
Props
Name | Type | Default | Description |
---|---|---|---|
name | string (from react-hook-form Path) | required | The field name (must match your form schema). |
label | string | The label displayed above the input. | |
type | 'text' | 'email' | 'number' | 'text' | The input type. |
placeholder | string | 'Input' | Placeholder text for the input. |
required | boolean | false | Marks the field as required. |
action | () => void | Optional action button on the right (e.g., clear/reset). | |
icon | ReactNode | Icon to display on the right side of the input. | |
loading | boolean | Shows a loading spinner on the right when true. | |
className | string | Additional CSS classes for the field container. | |
inputClass | string | Additional CSS classes for the input element. | |
iconClass | string | Additional CSS classes for the icon or action button. | |
disabled | boolean | false | Disables the input when true. |
Usage
<ShaddyForm>
<TextField
name="email"
label="Email"
type="email"
required
placeholder="Enter your email"
/>
</ShaddyForm>
Notes
- The
action
prop adds a button on the right (e.g., for clearing the field). Ificon
is provided, it will be shown inside the action button; otherwise, a default X icon is used. - If
loading
is true, a loading spinner appears on the right.