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.jsonGuidelines
- Always a visible
label. Placeholder is an example, never the label. prefix/suffixfor units and symbols ($, kg, .com);prefixAddon/suffixAddonfor attached boxes (https://, USD).type="password"adds a show/hide button automatically (revealable={false}to remove);showStrengthadds a 4-step meter.errorreplaces the hint and says how to fix it.requiredadds the asterisk and aria-required.- Sizes: sm 36 (desktop-dense only), md 44 (default), lg 52.
Props
| Prop | Type | Required |
|---|---|---|
label | string | No |
hint | React.ReactNode | No |
error | React.ReactNode | No |
required | boolean | No |
optional | boolean | No |
icon | string | No |
prefix | string | React.ReactNodeinline text/icon name/node before the value, e.g. '$' or 'https://' | No |
suffix | string | React.ReactNodeinline after the value, e.g. 'kg' or '.com' | No |
prefixAddon | React.ReactNodeattached box on the left, e.g. 'https://' | No |
suffixAddon | React.ReactNodeattached box on the right, e.g. 'USD' | No |
trailing | React.ReactNode | No |
clearable | boolean | No |
revealable | boolean | No |
showStrength | boolean | No |
onValueChange | (value: string) => void | No |
size | 'sm' | 'md' | 'lg' | No |
pill | boolean | No |
Also accepts everything in Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'>.