Navigated to /docs/ui/components/text-input

TextInput

Token-styled native input element for text-like values.

Preview

A live, theme-aware example rendered with the published component.

Loading preview…

Import

Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.

TSX
tsximport { TextInput } from "@tavojs/ui/text-input";

The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/text-input.

When to use

Use it when

Use TextInput as the actual text, email, password, URL, or similar native input control.

Choose something else when

TextInput does not generate a visible label or supporting messages. Wrap it in Field for label, hint, validation, required-state, and ARIA wiring.

Examples

These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.

TextInput example

TSXCreate: src/components/examples/TextInputExample1.tsx
tsximport { TextInput } from "@tavojs/ui/text-input";
import { Field } from "@tavojs/ui";

export function TextInputExample1() {
  return (
    <>
      <Field id="contact-email" label="Email"><TextInput name="email" type="email" placeholder="[email protected]" /></Field>
    </>
  );
}

Common props and defaults

A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.

PropTypeDefaultDescription
classNamestring

Optional class hook applied to the public root element owned by the component.
sizeSize

Configures size for this component.

Complete TypeScript API

Import from @tavojs/ui/text-input. Published exports: TextInput, TextInputProps.

TextInputProps

PropertyTypeRequiredDescription
classNamestring

No

Optional class hook applied to the public root element owned by the component.

sizeSize

No

Configures size for this component.

onChangeValueChangeHandler<HTMLInputElement>

No

Inherited onChange attribute accepted by TextInput.

onInputValueChangeHandler<HTMLInputElement>

No

Inherited onInput attribute accepted by TextInput.

State ownership and DOM target

ConcernContract
StateNo component state contract is exposed; the application owns the rendered content and surrounding behavior.
DOM targetNative input attributes target the owned form control; wrapper-specific props stay on the documented component root.

Anatomy and related components

This component exposes one public component root rather than a compound member API.

Limitations

TextInput does not generate a visible label or supporting messages. Wrap it in Field for label, hint, validation, required-state, and ARIA wiring.

Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.

Accessibility

Form components pass through native attributes and should be paired with visible labels or accessible names.

  • Use Field, FormLabel, FormControlLabel, or aria-label for labeling.

  • Preserve native input semantics whenever possible.

  • Expose validation with error text and aria-invalid where relevant.

Component status

ContractCurrent value
Maturitystable
Categoryforms
Component import@tavojs/ui/text-input
Explicit CSS import@tavojs/ui/css/text-input
PreviewInteractive preview available on this page