Skip to content

Input and TextArea ​

The text input, 32 pixels high or 28 with size="sm". TextArea is a field of a few lines, such as a commit message.

tsx
import { Input, TextArea } from '@adecore/ui';
tsx
import { Field, Input, TextArea } from '@adecore/ui';

export default function InputDemo() {
    return (
        <div className="flex w-80 flex-col gap-4">
            <Field label="Title">
                <Input placeholder="Add a title" />
            </Field>
            <Field label="Path">
                <Input mono defaultValue="src/components/Button.tsx" />
            </Field>
            <Input size="sm" aria-label="Filter" placeholder="Filter" />
            <Field label="Description">
                <TextArea rows={4} placeholder="What does this change?" />
            </Field>
            <TextArea size="sm" resize="vertical" aria-label="Commit message" placeholder="Commit message" />
        </div>
    );
}

size="sm" matches a small button, for a toolbar or an inline rename. mono uses the code font, for a branch or a path.

icon draws a Lucide icon before the text, 14 pixels or 12 with size="sm". The input then sits in a box that draws the field. className goes to that box; ref and the other props stay on the input.

For a value a person reads but does not type, such as a chosen folder, use readOnly. The value is muted and truncates, and stays copyable.

tsx
import { Button, Field, Input } from '@adecore/ui';
import { Folder, Search } from 'lucide-react';

export default function InputIconDemo() {
    return (
        <div className="flex w-80 flex-col gap-4">
            <Input icon={Search} aria-label="Search" placeholder="Search" />
            <Input icon={Search} size="sm" aria-label="Filter files" placeholder="Filter files" />
            <Field label="Folder">
                <div className="flex items-center gap-2">
                    <Input icon={Folder} readOnly value="~/Projects/launch-video" placeholder="No folder chosen" />
                    <Button variant="secondary">Choose</Button>
                </div>
            </Field>
        </div>
    );
}

end draws content after the text, such as a match count and an xs IconButton that clears the query. Like icon, it wraps the input in a box that takes className. Keep end set while the field is on screen (false when empty), or the input remounts and loses focus.

tsx
import { IconButton, Input } from '@adecore/ui';
import { formatNumber } from '@adecore/ui/format';
import { Search, X } from 'lucide-react';
import { useState } from 'react';

const FILES = ['Button.tsx', 'ButtonGroup.tsx', 'Input.tsx', 'Select.tsx', 'SplitButton.tsx'];

export default function InputEndDemo() {
    const [query, setQuery] = useState('button');
    const matches = FILES.filter((name) => name.toLowerCase().includes(query.toLowerCase())).length;

    return (
        <div className="w-80">
            <Input
                icon={Search}
                size="sm"
                aria-label="Filter files"
                placeholder="Filter files"
                value={query}
                onChange={(event) => setQuery(event.target.value)}
                end={
                    query !== '' && (
                        <>
                            <span className="text-xs text-text-faint tabular-nums">{formatNumber(matches)}</span>
                            <IconButton icon={X} size="xs" label="Clear filter" onClick={() => setQuery('')} />
                        </>
                    )
                }
            />
        </div>
    );
}

A TextArea is at least 64 pixels tall; rows makes it taller. size="sm" gives it compact text and padding. resize="vertical" adds a resize handle.

variant="bare" drops the border, ground and focus outline, on both, for a field inside a row or card that draws them. The card then shows focus itself, for example with has-[textarea:focus-visible]:outline-2 has-[textarea:focus-visible]:-outline-offset-1 has-[textarea:focus-visible]:outline-accent-on-surface.

tsx
import { Button, TextArea } from '@adecore/ui';

export default function TextAreaBare() {
    return (
        <div className="flex w-80 flex-col rounded-lg border border-border bg-surface-sunken has-[textarea:focus-visible]:outline-2 has-[textarea:focus-visible]:-outline-offset-1 has-[textarea:focus-visible]:outline-accent-on-surface">
            <TextArea variant="bare" size="sm" rows={3} aria-label="Commit message" placeholder="Commit message" />
            <div className="flex justify-end p-1.5">
                <Button size="sm" variant="primary">
                    Commit
                </Button>
            </div>
        </div>
    );
}

A form of lines, each a label and a bare input on one hairline, shows focus per line:

tsx
import { Input } from '@adecore/ui';

const LINE =
    'flex h-9 items-center gap-2 border-b border-border px-3 last:border-b-0 has-[input:focus-visible]:outline-2 has-[input:focus-visible]:-outline-offset-2 has-[input:focus-visible]:outline-accent-on-surface';

export default function InputBare() {
    return (
        <div className="flex w-96 flex-col overflow-hidden rounded-lg border border-border bg-surface">
            <label className={LINE}>
                <span className="w-16 shrink-0 text-xs text-text-muted">To</span>
                <Input variant="bare" placeholder="Name or address" />
            </label>
            <label className={LINE}>
                <span className="w-16 shrink-0 text-xs text-text-muted">Subject</span>
                <Input variant="bare" defaultValue="Q1 roadmap planning" />
            </label>
        </div>
    );
}

Inside a Field both take their id, aria-describedby and aria-invalid from it. Outside one, give them an aria-label.

Props ​

Input takes every prop of an <input> except its numeric size, plus:

PropTypeDefault
size'md' | 'sm''md'
monobooleanfalse
iconLucideIconDrawn in front of the text.
endReactNodeDrawn after the text, inside the field.
variant'field' | 'bare''field'

TextArea takes every prop of a <textarea>, plus:

PropTypeDefault
size'md' | 'sm''md'
resize'none' | 'vertical''none'
monobooleanfalse
variant'field' | 'bare''field'

InputProps and TextAreaProps are exported types.

Licenses and third-party notices are listed in each package.