Antares
Components

TextField

TextField is a single-line or multiline text input with optional label, description, and error message. Use it in forms for short answers (email, search, name) or longer content (comments). It supports optional leading and trailing text adornments (e.g. currency or units).

Features

  • Label, description, error: Optional label, helper text, and error message with proper accessibility
  • Adornments: Optional leadingText and trailingText for fixed text before or after the input (e.g. $, .00, px)
  • Controlled or uncontrolled: Use value and onChange for controlled state, or defaultValue for uncontrolled
  • Multiline: Set multiline to render a textarea instead of a single-line input
  • Validation states: Use isInvalid with errorMessage and isDisabled for validation and disabled state
  • React Aria integration: Built on React Aria TextField for accessibility and behavior

Installation

npm install --save @godaddy/antares

Props

The TextField component accepts the following props:

NameTypeDefault
description?string | undefined

Helper text shown below the frame.

defaultValue?string | undefined

Default value (uncontrolled).

errorMessage?string | undefined

Error message shown when invalid. Use with isInvalid.

isDisabled?boolean | undefined

Whether the input is disabled.

isInvalid?boolean | undefined

Whether the value is invalid. Use with errorMessage for validation.

isRequired?boolean | undefined

Whether user input is required before form submission.

label?string | undefined

Label text shown above the frame.

leadingText?string | undefined

Text rendered before the input (leading adornment).

multiline?boolean | undefined

When true, renders a textarea instead of a single-line input.

name?string | undefined

Name of the input element, used when submitting a form.

onChange?((value: string) => void) | undefined

Handler called when the value changes.

placeholder?string | undefined

Placeholder text when the input value is empty.

trailingText?string | undefined

Text rendered after the input (trailing adornment).

value?string | undefined

Current value (controlled).

validationBehavior?"native" | "aria" | undefined'native'

Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.

enterKeyHint?"search" | "enter" | "done" | "go" | "next" | "previous" | "send" | undefined

An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint).

style?StyleOrFunction<TextFieldRenderProps> | undefined

The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state.

className?ClassNameOrFunction<TextFieldRenderProps> | undefined'react-aria-TextField'

The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.

render?DOMRenderFunction<"div", TextFieldRenderProps> | undefined

Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: - You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). - Only a single root DOM element can be rendered (no fragments). - You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.

slot?string | null | undefined

A slot name for the component. Slots allow the component to receive props from a parent component. An explicit `null` value indicates that the local props completely override all props received from a parent.

Examples

Basic

Minimal usage with label and placeholder.

import { TextField, type TextFieldProps } from '@godaddy/antares';export function TextFieldBasic(props: TextFieldProps) {  return <TextField label="Name" placeholder="Enter your name" {...props} />;}

Controlled

Use value and onChange for controlled state.

import { useState } from 'react';import { Text, TextField } from '@godaddy/antares';export function TextFieldControlledExample() {  const [value, setValue] = useState('');  return (    <>      <TextField label="Email" placeholder="you@example.com" value={value} onChange={setValue} />      <Text>        <strong>Value:</strong> {value || '(empty)'}      </Text>    </>  );}
Value: (empty)

Invalid

Use isInvalid with errorMessage for validation feedback.

import { TextField } from '@godaddy/antares';export function TextFieldInvalidExample() {  return (    <TextField      label="Email"      placeholder="you@example.com"      errorMessage="Please enter a valid email address"      isInvalid      isRequired    />  );}
Please enter a valid email address

Disabled

Use isDisabled to prevent input.

import { TextField } from '@godaddy/antares';export function TextFieldDisabledExample() {  return <TextField label="Name" placeholder="Enter your name" defaultValue="Disabled value" isDisabled />;}

Adornments

Use leadingText and trailingText for fixed text before and after the input (e.g. currency).

import { TextField } from '@godaddy/antares';export function TextFieldAdornmentsExample() {  return (    <TextField      description="Use leadingText and trailingText to show fixed text before and after the input (e.g. currency)."      label="Amount"      leadingText="$"      placeholder="0.00"      trailingText=".00"    />  );}
Use leadingText and trailingText to show fixed text before and after the input (e.g. currency).

Multiline

Use multiline to render a textarea.

import { TextField, type TextFieldProps } from '@godaddy/antares';export function TextFieldMultilineExample(props: TextFieldProps) {  return <TextField label="Comment" placeholder="Enter your comment" multiline {...props} />;}

On this page