Input
A single-line text field with its label, helper text and error message built in.
Use an input for short, free-form text: a name, an email address, a search query. The label, description and error are part of the component, so they are always wired to the field for screen readers.
We send the receipt to this address.
import { Input } from "@aloxe/react";
export default function InputBasic() {
return (
<Input
label="Email"
type="email"
name="email"
placeholder="you@example.com"
description="We send the receipt to this address."
className="w-full max-w-sm"
/>
);
}Installation
npm i @aloxe/react @aloxe/tokensThen add the CSS imports from Installation.
Usage
import { Input } from "@aloxe/react";
<Input
label="Email"
type="email"
name="email"
description="We send the receipt to this address."
/>label is required. Native input props such as type, name, required, autoComplete and ref go to the <input>. className styles the wrapper, so use it for width.
Examples
States
Pass error to show the error state: a danger border, aria-invalid and the message linked to the field. Say how to fix the problem, not only that there is one. disabled dims the field and its label.
Change the plan from Billing.
import { Input } from "@aloxe/react";
export default function InputStates() {
return (
<div className="flex w-full max-w-sm flex-col gap-6">
<Input label="Project name" defaultValue="Billing dashboard" />
<Input
label="Workspace URL"
defaultValue="acme corp"
error="Use lowercase letters, numbers and hyphens."
/>
<Input
label="Plan"
defaultValue="Team"
disabled
description="Change the plan from Billing."
/>
</div>
);
}Leading icon
A 16 px icon before the text, for search or a known format. It is decorative. When the label is hidden with showLabel={false}, screen readers still announce it.
import { Input } from "@aloxe/react";
import { Search } from "lucide-react";
export default function InputLeadingIcon() {
return (
<Input
label="Search components"
showLabel={false}
type="search"
placeholder="Search"
leadingIcon={<Search />}
className="w-full max-w-sm"
/>
);
}Controlled
Pass value and onChange to control the value, for example to normalise it or validate as people type.
At least 3 characters: letters, numbers and hyphens.
Profile URL: aloxe.dev/@ada
"use client";
import { Input } from "@aloxe/react";
import { useState } from "react";
export default function InputControlled() {
const [handle, setHandle] = useState("ada");
const valid = /^[a-z0-9-]{3,}$/.test(handle);
return (
<div className="flex w-full max-w-sm flex-col gap-2">
<Input
label="Username"
value={handle}
onChange={(event) => setHandle(event.target.value.toLowerCase())}
description="At least 3 characters: letters, numbers and hyphens."
error={valid ? undefined : "Use at least 3 letters, numbers or hyphens."}
/>
<p className="aloxe-text-body-sm text-ax-text-secondary">
Profile URL: aloxe.dev/@{handle || "…"}
</p>
</div>
);
}Accessibility
| Key | Action |
|---|---|
| Tab | Moves focus to the input. |
| Shift + Tab | Moves focus to the previous field. |
- The label is always rendered.
showLabel={false}hides it visually and keeps it as the accessible name; don't rely on a placeholder as the label. descriptionanderrorare linked witharia-describedby, so they are read when the field gets focus.- Without an
errorprop, the browser's own validation message (for example fromrequired) shows once the field is validated.
API reference
Every part accepts className and renders a data-aloxe attribute you can target in CSS, such as [data-aloxe="input"].
Input
Extends Base UI Field + Input; other props go to the native <input>.
| Prop | Type | Default | Description |
|---|---|---|---|
| label (required) | ReactNode | The visible label and the input's accessible name. | |
| showLabel | boolean | true | false hides the label visually only. Screen readers still announce it. |
| description | ReactNode | Helper text under the input, linked with aria-describedby. | |
| error | ReactNode | Error message. Sets the error state: danger border, aria-invalid and the message linked to the input. | |
| leadingIcon | ReactNode | A 16 px decorative icon before the text, e.g. a search icon. | |
| disabled | boolean | false | Disables the input and dims the label. |
| value | string | number | string[] | Controlled value. Pair with onChange. | |
| defaultValue | string | number | string[] | Initial value when uncontrolled. | |
| className | string | Classes for the wrapper (label, input and messages), e.g. a width. Other props go to the <input>. |
Figma
Matches the Input component. Figma text properties Label, Value and Helper map to label, value and description; Show label maps to showLabel; the Leading icon swap maps to leadingIcon. The Error state is the error prop; disabled is disabled.
See Figma for where to get the file and how its names map to code.