Email Field
Web/MobileA labeled email field with icons, clear, description, and error. type is locked to email with matching autocomplete and inputMode.
برای ورود و بازیابی حساب از این ایمیل استفاده میشود.
Installation
pnpm dlx cubix-ui@latest add email-fieldUsage
import { MailIcon } from "lucide-react"
import {
EmailField,
EmailFieldClear,
EmailFieldControl,
EmailFieldDescription,
EmailFieldInput,
EmailFieldLabel,
} from "@/components/cubix/email-field"
<EmailField className="w-full max-w-sm">
<EmailFieldLabel>ایمیل</EmailFieldLabel>
<EmailFieldControl>
<MailIcon data-icon="inline-start" />
<EmailFieldInput defaultValue="amin@cubix.com" placeholder="example@cubix.com" />
<EmailFieldClear aria-label="پاک کردن" />
</EmailFieldControl>
<EmailFieldDescription>
برای ورود و بازیابی حساب از این ایمیل استفاده میشود.
</EmailFieldDescription>
</EmailField>
Composition
Same composition as Text Field. EmailFieldInput always renders type="email" with email autocomplete and inputMode. Addresses are Latin, so the input defaults to dir="ltr" while the text stays aligned with the surrounding form - a trailing @ or . no longer jumps to the wrong side in right-to-left forms.
EmailField
├── EmailFieldLabel
├── EmailFieldControl
│ ├── Icon data-icon="inline-start" | "inline-end"
│ ├── EmailFieldInput
│ └── EmailFieldClear
├── EmailFieldDescription
└── EmailFieldErrorAccessibility
EmailFieldLabel is wired to the input, and EmailFieldDescription and EmailFieldError are announced through aria-describedby. invalid sets aria-invalid on the input. Give EmailFieldClear a localized aria-label; it leaves the tab order while hidden.
Examples
Description
Add helper text below the control for format hints or guidance.
ترجیحاً از ایمیل سازمانی خود استفاده کنید.
Invalid
Set invalid on the root to apply destructive styles and show EmailFieldError.
Disabled
Disable the field to block interaction. The control uses a muted fill; label and description stay readable.
این فیلد فعلاً قابل ویرایش نیست.
Sizes
Two heights ship by default: default (40px) and lg (48px). Use className for any other size.
ارتفاع ۴۰ پیکسل
ارتفاع ۴۸ پیکسل
Icons
Place icons inside EmailFieldControl with data-icon like Button so spacing follows the reading direction.
Clear
EmailFieldClear appears inside the control while the input has a value and returns focus to the input after clearing.
In a form
Set name on the root so the value is submitted with the form, and pair the field with Cubix Button.
Custom styling
Every part accepts a className merged with the shipped cn helper. Here the input uses a filled surface instead of the default outline.
با className میتوانید ظاهر را سفارشی کنید.
API Reference
Note: Parts render data-slot attributes (email-field, email-field-label, email-field-control, email-field-input, email-field-clear, email-field-description, email-field-error) for targeting in tests and parent selectors. Use the same props on Base UI, React Aria, and Radix.
EmailField
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "default" | "lg" | "default" | Height for the input: default 40px, lg 48px. Inherited by EmailFieldInput and EmailFieldControl unless overridden. Use className for other heights. |
| disabled | boolean | false | Disables the field and prevents interaction. Forwarded to the control on every base. |
| invalid | boolean | false | Marks the field as invalid and shows EmailFieldError when present. |
| name | string | - | Identifies the field when a form is submitted. Forwarded to the input on every base. |
| className | string | - | Additional Tailwind classes merged with the root styles (last one wins). |
EmailFieldControl
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "default" | "lg" | - | Overrides the size from EmailField. Icon inset and height match the default and lg sizes. |
| children | React.ReactNode | - | Wrap EmailFieldInput with icons marked data-icon="inline-start" or "inline-end" (same as Button), and optionally EmailFieldClear. |
| className | string | - | Additional Tailwind classes merged with the control styles (last one wins). |
EmailFieldInput
| Prop | Type | Default | Description |
|---|---|---|---|
| type | "email" | "email" | Locked to email. Cannot be changed. inputMode is always email and spellCheck is always false. |
| size | "default" | "lg" | - | Overrides the size from EmailField. Default 40px, lg 48px. Use className for other heights. |
| autoComplete | string | "email" | Defaults to email. Override only when a different email autocomplete token is required. |
| dir | "ltr" | "rtl" | "auto" | "ltr" | Addresses are Latin, so the input defaults to ltr and a trailing @ or . stays in place while typing. Text still aligns with the surrounding form direction. |
| placeholder | string | - | Hint text shown when the input is empty. |
| className | string | - | Additional Tailwind classes merged with the input styles (last one wins). |
| ...props | Omit<React.ComponentProps<'input'>, 'type' | 'inputMode' | 'spellCheck'> | - | Native input attributes (value, onChange, name, required, ...) are forwarded. type, inputMode, and spellCheck stay locked for email. |
EmailFieldClear
| Prop | Type | Default | Description |
|---|---|---|---|
| aria-label | string | "Clear" | Accessible name for the clear button. Required when no visible text is present. |
| className | string | - | Additional Tailwind classes merged with the clear button styles (last one wins). |
EmailFieldLabel / Description / Error
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional Tailwind classes merged with the part styles (last one wins). |
| ...props | HTML attributes | - | Native attributes for the rendered element are forwarded. |