Components

Input

A text input component for forms and user data entry with built-in styling and accessibility features.

PreviewSource

Your API key is encrypted and stored securely.

Example requirements

Also uses: Field.

Installation

Complete the project setup first. The init command configures TypeScript, Vite, Tailwind CSS v4, and Preact compatibility.

CLI

Run init once using the installation guide, then add this component. The CLI copies the required source files and installs their exact dependencies with Bun.

bunx --bun github:LiasCode/shadcn-preact#main add input

Add --dry-run to review the changes. Existing modified files are protected; use --overwrite only when you want to replace them.

Manual installation / degit (optional)

1. Install dependencies

bun add --exact cn@0.4.0 preact@11.0.1 tw-animate-css@1.4.0

2. Copy the component with degit

Run this from your project root. It selects input.tsx, its local dependencies, and both licenses directly from the repository, then copies them into src/components/ui.

bunx degit@3.10.0 https://github.com/LiasCode/shadcn-preact#main ./.cache/shadcn-preact/input --files LICENSE.md,registry/ui/input.tsx,registry/ui/lib/utils.ts,registry/ui/primitives/LICENSE,registry/ui/primitives/field/control/FieldControl.tsx,registry/ui/primitives/input/Input.tsx,registry/ui/primitives/input/index.ts,registry/ui/primitives/internals/FieldRootContext.ts,registry/ui/primitives/internals/FieldsetRootContext.ts,registry/ui/primitives/internals/LabelableContext.ts,registry/ui/primitives/internals/createBaseUIEventDetails.ts,registry/ui/primitives/internals/empty.ts,registry/ui/primitives/internals/getReactElementRef.ts,registry/ui/primitives/internals/getStateAttributesProps.ts,registry/ui/primitives/internals/mergeObjects.ts,registry/ui/primitives/internals/resolveClassName.ts,registry/ui/primitives/internals/resolveStyle.ts,registry/ui/primitives/internals/types.ts,registry/ui/primitives/internals/useId.ts,registry/ui/primitives/internals/useIsoLayoutEffect.ts,registry/ui/primitives/internals/useMergedRefs.ts,registry/ui/primitives/internals/useRefWithInit.ts,registry/ui/primitives/internals/useRenderElement.ts,registry/ui/primitives/internals/useStableCallback.ts,registry/ui/primitives/merge-props/index.ts --force
mkdir -p ./src/components/ui
cp -R ./.cache/shadcn-preact/input/registry/ui/. ./src/components/ui/
cp ./.cache/shadcn-preact/input/LICENSE.md ./src/components/ui/LICENSE.md

The temporary copy lives in .cache/shadcn-preact/input. Existing components stay in place; shared source files are updated from main.

Selected source files (24)

Usage

import { Input } from "./components/ui/input"
<Input />

Examples

Basic

BasicSource

Field

Use Field, FieldLabel, and FieldDescription to create an input with a label and description.

FieldSource

Choose a unique username for your account.

Example requirements

Also uses: Field.

Field Group

Use FieldGroup to show multiple Field blocks and to build forms.

Field GroupSource

We'll send updates to this address.

Example requirements

Also uses: Button, Field.

Disabled

Use the disabled prop to disable the input. To style the disabled state, add the data-disabled attribute to the Field component.

DisabledSource

This field is currently disabled.

Example requirements

Also uses: Field.

Invalid

Use the aria-invalid prop to mark the input as invalid. To style the invalid state, add the data-invalid attribute to the Field component.

InvalidSource

This field contains validation errors.

Example requirements

Also uses: Field.

File

Use the type="file" prop to create a file input.

Select a picture to upload.

Example requirements

Also uses: Field.

Inline

Use Field with orientation="horizontal" to create an inline input. Pair with Button to create a search input with a button.

InlineSource
Example requirements

Also uses: Button, Field.

Grid

Use a grid layout to place multiple inputs side by side.

Example requirements

Also uses: Field.

Required

Use the required attribute to indicate required inputs.

RequiredSource

This field must be filled out.

Example requirements

Also uses: Field.

Badge

Use Badge in the label to highlight a recommended field.

BadgeSource
Example requirements

Also uses: Badge, Field.

Input Group

To add icons, text, or buttons inside an input, use the InputGroup component. See the Input Group component for more examples.

Input GroupSource
https://
Example requirements

Also uses: Field, Input Group.

bun add --exact lucide-preact@1.55.0

Button Group

To add buttons to an input, use the ButtonGroup component. See the Button Group component for more examples.

Button GroupSource
Example requirements

Also uses: Button, Button Group, Field.

Reference

See the official Input documentation for composition patterns and API details. This page uses the Preact port and examples from the pinned upstream revision.

Component source