Shadcn Input
A multi-purpose Input component (InputBlock) with password toggles, a password-strength meter, autocomplete suggestions, and several field styles.
About Shadcn Input
What it is. InputBlock is a styled text-field component supporting default, filled, underlined, glow, pill and password-strength variants, plus built-in password visibility toggles and keyboard-navigable autocomplete suggestions.
How it is built. Extends native React.InputHTMLAttributes<HTMLInputElement> with Tailwind CSS styling and focus and error rings that follow --primary or color. Suggestions use the ARIA combobox and listbox roles, and the strength bar has role="meter". It forwards its ref to the input and needs only lucide-react.
When to use it. Use InputBlock for text, email, password, search, and autocomplete inputs. For drag-and-drop file selection, use File Upload; for verification codes, use OTP Input.
For AI agents
Hand your agent this brief or the Markdown page, not a screenshot.
When to use
- Standard, filled, underlined, or capsule-pill text inputs with labels, icons, and validation errors
- Password fields with built-in show/hide toggle (
type="password") or live strength meter (variant="password-strength") - Free-text inputs with filterable
suggestionsautocomplete
When not to use
- Drag-and-drop file inputs — use File Upload
- Multi-digit verification codes — use OTP Input
- Fixed-option dropdowns — use Select
Agent notes
- Named export:
import { InputBlock } from "@/components/custom/blocks/InputBlock" - Pass
suggestions: string[]+onSuggestionSelectfor autocomplete; passfloatingLabelwithvariant="password-strength"to float the label onto the top border labelrenders a<label>that is not linked to the input anderroris not wired toaria-invalidoraria-describedby, so passaria-labelandaria-invalidto the input yourself where screen readers matter- The
password-strengthvariant always renders a password field with its own toggle and a generate-password button, whatevertypeis - Install also copies
input-theme.tsnext toInputBlock.tsx
For AI agents5 variants. Ask the user which one.
Ask before you pick. This page has 5 variants. If the user has not named one and has not asked you to choose for them, ask which they want before you install anything or write code, and show every option with its live link. If they ask you to choose, pick from each variant's best-for and avoid-if lines against their brief, and say why. If the user named a variant, use it and do not ask.
All 5 options as live previews: https://avaraui.com/view/input
When to use it. A text field with labels, helper text, a password toggle and autocomplete suggestions, in four styles: bordered, filled, underlined and a pill badge.
When to use something else
- File Upload: for drag-and-drop or file selection fields.
Gotchas
- All four are looks of the one `input` item: install it once and set `variant` from the index.
- A password field is `inputType="password"` (the show/hide toggle comes with it) and autocomplete is the `suggestions` prop: neither is a different design.
The 5 variants
Password Strength password-strength
A password field with a 4-segment strength meter, Weak/Fair/Good/Strong label, and live criteria checklist.
- Best for: sign-up or password-reset forms where users need immediate strength feedback
- Avoid if: you only need a plain masked password input without rules
- Traits: 4-segment meter, live checklist, Weak/Fair/Good/Strong tones
- Install:
npx shadcn@latest add @avara-ui/input - Docs section
Bordered default
The default bordered box, with an optional label above and helper text below.
- Best for: a standard form field that should look clearly like a field
- Avoid if: the form's design system calls for a flatter field
- Traits: bordered box, default look
- Install:
npx shadcn@latest add @avara-ui/input - Docs section
Filled filled
A solid, low-contrast field with no visible border at rest.
- Best for: a soft, modern form on a light background
- Avoid if: the field must stand out against a similar-coloured surface
- Traits: solid fill, no border at rest
- Install:
npx shadcn@latest add @avara-ui/input - Docs section
Underlined underlined
The chrome is reduced to a single baseline rule.
- Best for: a minimal, editorial form
- Avoid if: fields must be easy to spot in a dense form
- Traits: baseline rule only
- Install:
npx shadcn@latest add @avara-ui/input - Docs section
Pill badge pill
The input sits in a capsule with a vertical divider after a leading icon in a segregated badge.
- Best for: a search or single-field sign-up with a leading icon
- Avoid if: you have a long multi-field form
- Traits: capsule shape, leading icon badge, vertical divider
- Install:
npx shadcn@latest add @avara-ui/input - Docs section
- Markdown
- /docs-md/nextjs-input.md
- Install
npx shadcn@latest add https://avaraui.com/r/input.json- Registry name
@avara-ui/input, through the shadcn MCP server- Index
- llms.txt lists every page, or add the agent skill once
Props Reference
This component extends React.InputHTMLAttributes<HTMLInputElement>, meaning you can pass any standard input prop (like onChange, value, name, disabled, etc.).
| Prop | Type | Default | Description |
|---|---|---|---|
type | "text" | "password" | "email" | "number" | "file" | "text" | Determines the behavior. |
suggestions | string[] | undefined | Autocomplete list. Focus shows it, typing filters it
(case-insensitive, matched letters highlighted), and a click or
Enter writes the suggestion into the field. Ignored for
|
onSuggestionSelect | (value: string) => void | undefined | Fired after a suggestion is written into the field. The regular
|
maxSuggestions | number | 8 | Maximum rows shown at once; further matches scroll. |
inputSize | "sm" | "md" | "lg" | "md" | Uniformly scales the height, padding, text size, and icon size of the input or dropzone. |
variant | "default" | "filled" | "underlined" | "glow" | "pill" | "password-strength" | "default" | Determines the visual styling of the borders, background, and focus rings. |
color | "primary" | "lavender" | "indigo" | "rose" | "emerald" | "zinc" | string | "primary" | Applies the global color theme to the focus ring, glow shadow, and
drag-active states. The default follows your theme's |
label | string | undefined | Renders a bold, accessible label directly above the input. |
floatingLabel | boolean | false | Floats the label onto the top border when focused or filled. Used by the |
helperText | string | undefined | Subtle instructional text rendered below the input. |
error | string | undefined | If provided, turns the input red, adds an alert icon, and replaces the helper text with the error message. |
onFilesChange | (files: File[]) => void | undefined | Called with the chosen files when |
disabled | boolean | false | Disables interactions and applies a faded, read-only style. |
leftIcon / rightIcon | ReactNode | undefined | Standard Mode Only: Injects an icon or element into the left or right side of the input field. |
Works with other components
- Compose
InputBlockinside Form or Auth Forms with Button. - Pair with Select and Date Picker for matching
defaultandunderlinedfield styling. - Embed inside Dialog for edit-profile and modal forms.
- Use OTP Input instead for one-time codes, and File Upload for drag-and-drop files.
How do I enable the show/hide password toggle in InputBlock?
Pass type="password" to InputBlock. The visibility toggle button is rendered automatically and no extra prop is needed. With variant="password-strength" the toggle is always present, and its button is labelled "Show password" or "Hide password" for screen readers.
How does InputBlock autocomplete work?
Pass a string array to suggestions. Focusing the field opens the list, and typing filters it to entries that contain the typed text anywhere, ignoring case, with the match highlighted. Arrow keys move, Enter picks, and Escape or Tab closes. onSuggestionSelect fires alongside onChange.
How does the InputBlock password strength meter score a password?
With variant="password-strength" the meter counts four rules: at least 12 characters, upper and lower case, a number, and a special character. The label runs Weak, Fair, Good, Strong. Passwords containing common patterns such as "password" or "1234" show "Commonly guessed" and stay at Weak. A sparkle button generates a 16-character password.
How do I show a validation error on InputBlock?
Pass the message as error. The field turns red, an alert icon appears, and the message replaces helperText. Because InputBlock forwards its ref and spreads input props, {...register("email")} from react-hook-form works, with error={errors.email?.message}. Add aria-invalid yourself for assistive technology.
How do I change the InputBlock size and colour?
inputSize accepts sm, md (default) or lg and scales height, padding, text and icons. color accepts primary (default, following your theme), lavender, indigo, rose, emerald, zinc or a hex string, and tints the focus ring, glow and autocomplete highlight.
Is InputBlock accessible to screen readers?
Partly. The autocomplete list uses combobox, listbox and option roles with aria-activedescendant, and the strength bar is a labelled meter. The label element is not linked to the input and errors are not announced, so pass aria-label and aria-invalid to the input directly. It has no next/* imports.