GitHub
Core
Glass
Brutal
Humanist

Text Input

Text inputs allow users to enter and edit text. They support floating labels, validation states, leading/trailing elements, and multiple input types.

TextInput Playground

TextInput Playground
Preview
Code
Controls
Size:
Small
Medium
Large
Status:
Default
Error
Success
Input Type:
Default
Leading Text
Trailing Text
Country
Button
Floating Label:
Supporting Text:
Read Only:
Masked:
Leading Icon:
Trailing Icon:
Disabled:

Installation

You can add the text input component to your project manually:

1

Install the following dependencies:

npm install class-variance-authority clsx tailwind-merge @phosphor-icons/react @floating-ui/react @react-aria/focus @react-aria/interactions
2

Copy and paste the following code into your project.

Loading source code...
3

Update the import paths to match your project setup.

Update the import aliases (e.g. @/components, @/utils) in the copied files to match your project's path configuration.

Basic Usage

import { TextInput } from '@versaui/ui/components/TextInput';

<TextInput label="Email" placeholder="Enter email" />

Floating Label

The label floats above the input when focused or has a value:

<TextInput label="Username" showFloatingLabel />

// Without floating label
<TextInput label="Username" showFloatingLabel={false} placeholder="Enter username" />

Sizes

Three sizes are available — small, medium, and large:

<TextInput size="large" label="Large" />
<TextInput size="medium" label="Medium" />
<TextInput size="small" placeholder="Small (no label)" />

Validation States

Set status to show validation states:

<TextInput
  label="Email"
  status="error"
  errorText="Invalid email address"
/>

<TextInput
  label="Username"
  status="success"
  helperText="Username is available"
/>

Input Types

Leading Text

<TextInput
  label="Website"
  inputType="leadingText"
  leadingText="https://"
/>

Trailing Text

<TextInput
  label="Email"
  inputType="trailingText"
  trailingText="@example.com"
/>

Country

<TextInput
  label="Phone"
  inputType="country"
  selectedCountry="us"
/>

Button

<TextInput
  label="Copy Link"
  inputType="button"
  buttonIcon={<Copy />}
/>

Inline

<TextInput
  label="Amount"
  inputType="inline"
/>

Disabled and Read-Only

<TextInput label="Disabled" disabled value="Cannot edit" />
<TextInput label="Read Only" readOnly value="Read only value" />

Masked Input

<TextInput label="Password" masked />

Accessibility

  • Uses native <input> for full accessibility
  • Floating label serves as accessible label via aria-label
  • Error and helper text linked via aria-describedby
  • Required state announced via aria-required
  • Disabled and read-only states properly communicated
  • Focus ring visible on keyboard navigation

TextInput Props

PropTypeDefaultDescription
size'large' | 'medium' | 'small''medium'Input size.
inputType'default' | 'leadingText' | 'trailingText' | 'country' | 'button' | 'inline''default'Input layout variant.
status'default' | 'error' | 'success''default'Validation status.
labelstring''Floating label text.
placeholderstringPlaceholder text.
showFloatingLabelbooleantrueUse floating label animation.
helperTextstringHelper text below input.
errorTextstringError text (shown on error status).
showSupportingTextbooleantrueShow supporting text area.
disabledbooleanfalsePrevents interaction.
readOnlybooleanfalseRead-only state.
requiredbooleanfalseMark as required.
maskedbooleanfalseMask input characters with password toggle.
leadingIconReactNodeIcon at the start of input.
trailingIconReactNodeIcon at the end of input.
showLeadingIconbooleantrueShow leading icon.
showTrailingIconbooleantrueShow trailing icon.
leadingTextstringText prefix (leadingText type).
trailingTextstringText suffix (trailingText type).
buttonIconReactNodeIcon for button variant.
selectedCountryCountryCode'us'Country code for country variant.
onCountryChange(country: CountryCode) => voidCountry selection handler.

On this page