Input
shadcn-htmx/inputFreeComponent
Native <input> with shadcn styling, sized for htmx live-validation patterns. Ships in five flavours.
Live preview
live · rendered by the registry
Rendered by shadcn-htmx on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn-htmx.productdevbook.com/r/input.jsonSource
1/** @jsxImportSource hono/jsx */2import { cn, type ClassValue } from "@/registry/lib/cn"34// Native <input> with shadcn styling. Source of truth:5// repos/shadcn-ui/apps/v4/registry/new-york-v4/ui/input.tsx6//7// We render a real <input> so every native behaviour is preserved:8// constraint validation (required, pattern, min/max), client-side autofill,9// browser autocomplete, and the input-mode keyboards on mobile.1011export type InputType =12 | "text"13 | "password"14 | "email"15 | "number"16 | "search"17 | "tel"18 | "url"19 | "date"20 | "time"21 | "datetime-local"22 | "month"23 | "week"24 | "color"25 | "file"26 | "hidden"2728const base =29 "flex h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none " +30 "selection:bg-primary selection:text-primary-foreground " +31 "file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground " +32 "placeholder:text-muted-foreground " +33 "disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 " +34 "md:text-sm dark:bg-input/30 " +35 "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 " +36 "aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 " +37 // htmx-request: dim while a request triggered by/targeting this input is38 // in flight (e.g. live-validation patterns).39 "[&.htmx-request]:opacity-70"4041export function inputClasses(opts?: { class?: ClassValue }): string {42 return cn(base, opts?.class)43}4445type InputProps = {46 type?: InputType47 class?: ClassValue48 id?: string49 name?: string50 value?: string | number51 defaultValue?: string | number52 placeholder?: string53 required?: boolean54 disabled?: boolean55 readonly?: boolean5657 // String/numeric constraints. The browser enforces these natively when the58 // input is inside a <form> that submits.59 minLength?: number60 maxLength?: number61 min?: number | string62 max?: number | string63 step?: number | string64 pattern?: string6566 // Mobile UX: hint to the OS keyboard layout (numeric, decimal, email, …)67 // and the Enter key label (done, search, send, …).68 inputmode?: "none" | "text" | "decimal" | "numeric" | "tel" | "search" | "email" | "url"69 enterkeyhint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send"7071 // Submits the text directionality (ltr/rtl) as a separate form field72// … truncated
More from shadcn-htmx
All 83 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | shadcn-htmx | Components | Free | no deps | |
| Active Searchactive-search | shadcn-htmx | Components | Free | no deps | |
| Alertalert | shadcn-htmx | Components | Free | no deps | |
| Alert Dialogalert-dialog | shadcn-htmx | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | shadcn-htmx | Components | Free | no deps | |
| Auto Gridauto-grid | shadcn-htmx | Components | Free | no deps | |
| Autocompleteautocomplete | shadcn-htmx | Components | Free | no deps | |
| Autosize Textareaautosize-textarea | shadcn-htmx | Components | Free | no deps |
