Getting started

Actions

Forms

Layout

Navigation

Overlays

Feedback

Data display

Controllers

Helpers

Recipes

Input

Inputs capture single-line text, numbers, emails, and other native input types with Radiant sizing and focus styles.

Try it

Usage

Wrap inputs in RuiField for labels and validation. Set type and placeholder as needed.

import { RuiInput } from '@ecopages/radiant-ui/input';
import { RuiField } from '@ecopages/radiant-ui/field';
import { RuiLabel } from '@ecopages/radiant-ui/label';

<RuiField>
  <RuiLabel>Email</RuiLabel>
  <RuiInput name="email" type="email" placeholder="you@example.com" />
</RuiField>

Choose the right type

Use email, url, and tel to trigger appropriate mobile keyboards. Use password for credential fields.

Marked for Field discovery

RuiInput sets data-rui-control so RuiField can wire labels, validation, and ARIA. Prefer it over a bare <input> inside forms.

Input masks

Pass a mask pattern for structured entry like phone numbers or credit card segments.

While you type or paste in the middle of a value, existing slot characters shift and the pattern redraws the literals. Typing inside fixed text keeps it whole and reads the typed text as if it came right after it, so 0 typed between 3 and 4 of +34(7 for +{34}(000 gives +34(07. Deleting, cutting or dragging out a selection removes the editable characters it covers, including a whole supplementary character if the selection covers part of it. For [0]{AB}-00, deleting AB-1 from AB-12 leaves AB-2. At a collapsed caret, Backspace or Delete on a generated literal removes the nearest slot character in that direction, if one exists. The caret follows slots across supplementary Unicode literals such as 🟢.

Typing a leading literal alone leaves an empty field empty. It appears as soon as the first slot is filled. Typing fixed text shows the part that matched, so 7 in +{7} 000 displays +7 and A in {AB}-00 displays A. Typing - after 123 for 000[-00] opens the optional section and displays 123-. Backspace over that separator, or deleting a selection that holds it and the digits after it, closes the empty section, so deleting -4 from 123-4 leaves 123.

With a mask, on:input receives the formatted edit. During IME composition, the browser keeps the provisional text. When composition ends, RuiInput formats it and passes the compositionend event to on:input. Safari then fires an input event, which is not passed on when it leaves that value unchanged, so on:input runs once per composition. A re-render of the input during a composition does not lose where it started.

Input groups

Use RuiInputGroup to add leading prefixes, trailing icons, or inline buttons around RuiInput. See the Input Group page for the full API.

import { RuiField } from '@ecopages/radiant-ui/field';
import { RuiInput } from '@ecopages/radiant-ui/input';
import {
  RuiInputGroup,
  RuiInputGroupAddon,
  RuiInputGroupText,
} from '@ecopages/radiant-ui/input-group';
import { RuiLabel } from '@ecopages/radiant-ui/label';

<RuiField>
  <RuiLabel>Website URL</RuiLabel>
  <RuiInputGroup>
    <RuiInputGroupAddon>
      <RuiInputGroupText>https://</RuiInputGroupText>
    </RuiInputGroupAddon>
    <RuiInput name="url" placeholder="example.com" />
  </RuiInputGroup>
</RuiField>

Theming

RuiInput consumes semantic surface + status roles, never Tailwind palette steps:

State / partCSS roles
Baseborder, background, on-background
Focusfocus-ring
Invalid (aria-invalid)error border
Disabledopacity-disabled

Geometry comes from control tokens: --size-control-md height, --radius-control corner, --space-control-x inline padding, the same tokens RuiButton uses, so form rows align. Override colors at the theme layer, not in component CSS.

Accessibility

  • Every input needs a visible label; placeholders are not substitutes.
  • Disabled inputs should explain why editing is unavailable.
  • Use type attributes that match the expected data format.

API

RuiInput is a presentational JSX view over a native <input>, no custom element. It sets data-rui-control so RuiField can wire labels, validation, and ARIA.

Props

PropTypeDefaultDescription
valuestringControlled value.
typestringtextNative input type (email, password, tel, …).
placeholderstringPlaceholder text.
disabledbooleanfalseDisabled state.
namestringForm field name.
idstringInput id (auto-wired by RuiField).
aria-labelstringAccessible name when there is no visible label.
maskstringPattern; 0 digit, a letter, * any char, {text} fixed text, [...] optional section, \ escape. See Masks.
definitionsRecord<string, 'digit' | 'letter' | 'any' | RegExp>Extra slot characters for mask, for example { X: /[A-F]/ }; a g or y flag on the RegExp is ignored.
on:input / on:change / on:blur(e: Event) => voidEvent handlers.
Native <input> attributesrequired, autocomplete, pattern, min, max, readonly, and other unprefixed native attributes type-check and render, except mask and definitions (peeled). inputmode is yours when you set it; without it, a mask whose slots are all digits sets numeric. An authored placeholder wins over the one the mask gives.

CSS classes

Public classes on the rendered element (documented via @cssclass):

ClassDescription
.rui-inputInput root; control-height, rounded, bordered surface.

Theme roles

PartCSS variables consumed
Base--border, --background, --on-background
Focus ring--focus-ring
Invalid--error
Geometry--size-control-md, --radius-control, --space-control-x