DocsComponentsTemplatesThemesGitHub

TextField

Labelled input with prefix/suffix, attached add-ons, password reveal, strength meter, clear button, sizes and validation states.

Code

import * as React from 'react';
import { TextField } from '@fruit-labs/design';

export default function Demo() {
  return (
    <div
      style={{
        display: 'grid',
        gridTemplateColumns: 'repeat(2,minmax(0,1fr))',
        gap: 16,
      }}
    >
      <TextField label="Full name" required defaultValue="Ada Lovelace" clearable />
      <TextField label="Website" prefixAddon="https://" placeholder="yourcompany" suffix=".com" />
      <TextField
        label="Price"
        prefix="$"
        suffixAddon="USD"
        inputMode="decimal"
        defaultValue="49.00"
      />
      <TextField label="Weight" suffix="kg" size="sm" defaultValue="72" />
      <TextField
        label="Password"
        type="password"
        icon="lock"
        defaultValue="Fruit-2026!"
        showStrength
        required
      />
      <TextField
        label="Email"
        type="email"
        icon="mail"
        defaultValue="ada@"
        error="Enter a full email address, like name@company.com."
      />
    </div>
  );
}

Prefix, suffix and error

import { TextField } from '@fruit-labs/design';

export default function Example() {
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 12, maxWidth: 560 }}>
      <TextField label="Website" prefixAddon="https://" placeholder="example.com" />
      <TextField label="Weight" suffix="kg" type="number" />
      <TextField label="Email" defaultValue="ada@" error="Enter a full email address." />
    </div>
  );
}

Install

From npm:

npm install @fruit-labs/design

import { TextField } from '@fruit-labs/design';

Or copy the TypeScript source into your project:

npx shadcn@latest add https://design.fruitlabs.online/r/text-field.json

Guidelines

  • Always a visible label. Placeholder is an example, never the label.
  • prefix/suffix for units and symbols ($, kg, .com); prefixAddon/suffixAddon for attached boxes (https://, USD).
  • type="password" adds a show/hide button automatically (revealable={false} to remove); showStrength adds a 4-step meter.
  • error replaces the hint and says how to fix it. required adds the asterisk and aria-required.
  • Sizes: sm 36 (desktop-dense only), md 44 (default), lg 52.

Props

PropTypeRequired
labelstringNo
hintReact.ReactNodeNo
errorReact.ReactNodeNo
requiredbooleanNo
optionalbooleanNo
iconstringNo
prefixstring | React.ReactNode
inline text/icon name/node before the value, e.g. '$' or 'https://'
No
suffixstring | React.ReactNode
inline after the value, e.g. 'kg' or '.com'
No
prefixAddonReact.ReactNode
attached box on the left, e.g. 'https://'
No
suffixAddonReact.ReactNode
attached box on the right, e.g. 'USD'
No
trailingReact.ReactNodeNo
clearablebooleanNo
revealablebooleanNo
showStrengthbooleanNo
onValueChange(value: string) => voidNo
size'sm' | 'md' | 'lg'No
pillbooleanNo

Also accepts everything in Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'>.

Edit this example on GitHub