@hoag/ui — UI components built with shadcn, Radix UI & Tailwind CSS
Components
Input

Input

Displays a standard text input field.

Installation

npx shadcn@latest add input

Usage

import { Input } from "@hoag/ui/input";
 
<Input placeholder="Enter your email" />;

In this repo, the implementation is already available at packages/ui/src/common/data-input/input/input.tsx.

Basic

<Input placeholder="Default input" />
<Input type="email" placeholder="name@example.com" />

Input Types

<Input type="text" placeholder="Text" />
<Input type="password" placeholder="Password" />
<Input type="number" placeholder="Number" />
<Input type="date" />

States

<Input value="Read only value" readOnly />
<Input disabled value="Disabled input" />
<Input aria-invalid placeholder="Invalid input" className="border-red-500 focus-visible:ring-red-500" />

With Label

<Label htmlFor="email">Email</Label>
<Input id="email" type="email" placeholder="you@example.com" />

Required Field

<Input label="Full name" isRequired placeholder="Nguyen Van A" />

Helper & Error Text

We'll only use this for account notifications.
Please enter a valid company email address.
<Input
  label="Email"
  placeholder="you@example.com"
  helpText="We'll only use this for account notifications."
/>
 
<Input
  label="Work email"
  value="not-an-email"
  readOnly
  isError
  errorText="Please enter a valid company email address."
/>

With Addons

https://
VND
<Input label="Website" addonBefore="https://" placeholder="your-domain.com" />
<Input label="Amount" addonAfter="VND" placeholder="100000" type="number" />

Clearable Input

<Input
  label="Search"
  value={value}
  onChange={(e) => setValue(e.target.value)}
  showRemoveIcon
  onClearValue={() => setValue("")}
/>

Sizes

<Input size="default" placeholder="Default size (h-8)" />
<Input size="md" placeholder="Medium size (h-9)" />
<Input size="lg" placeholder="Large size (h-10)" />
<Input size="xl" placeholder="Extra large size (h-11)" />
<Input size="2xl" placeholder="2X large size (h-12)" />

Sizes with Label

<Input size="default" label="Email" placeholder="Default (h-8)" />
<Input size="md" label="Email" placeholder="Medium (h-9)" />
<Input size="lg" label="Email" placeholder="Large (h-10)" />
<Input size="xl" label="Email" placeholder="Extra Large (h-11)" />
<Input size="2xl" label="Email" placeholder="2X Large (h-12)" />

Form-like Group

optional
<div className="space-y-4">
  <Input label="First name" placeholder="An" />
  <Input label="Last name" placeholder="Nguyen" />
  <Input label="Company" placeholder="Acme Inc." addonAfter="optional" />
</div>

API Reference

PropTypeDefaultDescription
size"default" | "md" | "lg" | "xl" | "2xl""default"Input size variant (h-8, h-9, h-10, h-11, h-12 respectively). 2xl uses 16px font.
labelReact.ReactNodeundefinedLabel shown above the input.
isRequiredbooleanfalseShow required indicator next to label.
isErrorbooleanfalseMarks input as error state.
helpTextReact.ReactNodeundefinedHelper text below input.
errorTextReact.ReactNodeundefinedError text below input (when isError).
addonBeforeReact.ReactNodeundefinedContent rendered before input content area.
addonAfterReact.ReactNodeundefinedContent rendered after input content area.
showRemoveIconbooleantrueShow clear icon when input has value.
onClearValue() => voidundefinedCallback fired when clear icon is clicked.
inputClassNamestringundefinedExtra classes for the native <input>.
wrapperClassNamestringundefinedExtra classes for outer wrapper.