Email Field

Web/Mobile

A 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-field --base aria

Usage

Import
import { MailIcon } from "lucide-react"

import {
  EmailField,
  EmailFieldClear,
  EmailFieldControl,
  EmailFieldDescription,
  EmailFieldInput,
  EmailFieldLabel,
} from "@/components/cubix/email-field"
Example
<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.

Structure
EmailField
├── EmailFieldLabel
├── EmailFieldControl
│   ├── Icon data-icon="inline-start" | "inline-end"
│   ├── EmailFieldInput
│   └── EmailFieldClear
├── EmailFieldDescription
└── EmailFieldError

Accessibility

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

PropTypeDefaultDescription
size"default" | "lg""default"Height for the input: default 40px, lg 48px. Inherited by EmailFieldInput and EmailFieldControl unless overridden. Use className for other heights.
disabledbooleanfalseDisables the field and prevents interaction. Forwarded to the control on every base.
invalidbooleanfalseMarks the field as invalid and shows EmailFieldError when present.
namestring-Identifies the field when a form is submitted. Forwarded to the input on every base.
classNamestring-Additional Tailwind classes merged with the root styles (last one wins).

EmailFieldControl

PropTypeDefaultDescription
size"default" | "lg"-Overrides the size from EmailField. Icon inset and height match the default and lg sizes.
childrenReact.ReactNode-Wrap EmailFieldInput with icons marked data-icon="inline-start" or "inline-end" (same as Button), and optionally EmailFieldClear.
classNamestring-Additional Tailwind classes merged with the control styles (last one wins).

EmailFieldInput

PropTypeDefaultDescription
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.
autoCompletestring"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.
placeholderstring-Hint text shown when the input is empty.
classNamestring-Additional Tailwind classes merged with the input styles (last one wins).
...propsOmit<React.ComponentProps<'input'>, 'type' | 'inputMode' | 'spellCheck'>-Native input attributes (value, onChange, name, required, ...) are forwarded. type, inputMode, and spellCheck stay locked for email.

EmailFieldClear

PropTypeDefaultDescription
aria-labelstring"Clear"Accessible name for the clear button. Required when no visible text is present.
classNamestring-Additional Tailwind classes merged with the clear button styles (last one wins).

EmailFieldLabel / Description / Error

PropTypeDefaultDescription
classNamestring-Additional Tailwind classes merged with the part styles (last one wins).
...propsHTML attributes-Native attributes for the rendered element are forwarded.