Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Inline Form for Ark UI

A newsletter row with the email field and Subscribe side by side, and a label that is hidden on screen.

Email and Subscribe sit on one row. The Email label is hidden visually and still names the field. The address must be valid, or the error shows under the field.

Use it in a footer or a banner where a stacked form is too tall. A visible label is a normal Field. In React, Ark UI still ties that hidden label to the field.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Usage

<form
  className="flex w-full max-w-md items-start gap-2"
  onSubmit={form.handleSubmit(onSubmit)}
>
  <Controller
    control={form.control}
    name="email"
    render={({ field, fieldState }) => (
      <Field className="flex-1" invalid={fieldState.invalid}>
        <FieldLabel className="sr-only">Email</FieldLabel>
        <Input {...field} placeholder="Enter your email" type="email" />
        <FieldError>{fieldState.error?.message}</FieldError>
      </Field>
    )}
  />
  <Button type="submit">Subscribe</Button>
</form>

FAQ

How is the email and button kept on one row?

The form is flex items-start gap-2 inside max-w-md. The email Field has flex-1, and Subscribe is a type="submit" button beside it.

Why is the Email label sr-only?

FieldLabel has className="sr-only", so the input keeps its accessible name, Email, without a visible label. The visible hint is the placeholder Enter your email.

Where does the email error show?

FieldError is inside the Field, under the input. The message is Please enter a valid email address., from z.email().

What value does Subscribe accept?

email must pass z.email(). defaultValues starts it as an empty string, and form.handleSubmit(onSubmit) logs the address only after the check passes.

What type is the input?

The Input sets type="email" and spreads the field from the Controller named email.

When does validation run?

useForm doesn't set mode, so the check runs on submit. The row is items-start, so when the message appears under the input the button stays aligned with the field.

API Reference

Field

Sets invalid={fieldState.invalid}. The rest is on the Field page.

Input

Sets field, placeholder="Enter your email" and type="email". The rest is on the Input page.

Button

Sets type="submit". The rest is on the Button page.