Input
nswds-ui/inputFreeComponent
A text input built on the Base UI input primitive with NSW form styling.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/digitalnsw/nswds-ui/main/apps/registry/public/r/input.jsonSource
1'use client'23import { Input as InputPrimitive } from '@base-ui/react/input'4import * as React from 'react'56import { cn } from '@/lib/utils'78function Input({ className, type, ref, ...props }: React.ComponentProps<'input'>) {9 return (10 <InputPrimitive11 ref={ref}12 type={type}13 data-slot='input'14 data-type={type}15 className={cn(16 // No `outline-none` here: it sets `--tw-outline-style: none` globally17 // on the element, which then suppresses the focus outline below18 // (which reads `outline-style: var(--tw-outline-style)`).19 'h-12 w-full min-w-0 rounded-sm px-4 py-2 text-base motion-safe:transition-colors',20 // Every colour routes through the --input-* semantic tokens (layer 3,21 // theme.css / the registry theme item). Dark mode and brand themes22 // restyle the input by remapping tokens — no dark: variants here.23 'border border-(--input-border) bg-(--input-surface) text-(--input-foreground)',24 // Hover25 'hover:bg-(--input-surface-hover)',26 // Focus — `focus-visible:` per the design-system policy (matches27 // Button/Link). For text fields this is behaviour-preserving:28 // browsers flag keyboard-editable controls as :focus-visible even29 // when focused by pointer, so the ring still shows on click.30 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--input-ring)',31 // File input slot32 'file:inline-flex file:h-8 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-(--input-foreground)',33 // Placeholder styles34 'placeholder:text-(--input-placeholder)',35 // Disabled36 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',37 // Invalid — 2px danger border, danger hover surface (Figma error variants)38 'aria-invalid:border-2 aria-invalid:border-(--input-invalid-border) aria-invalid:hover:bg-(--input-invalid-surface-hover) aria-invalid:focus-visible:outline-(--input-invalid-ring)',39 className,40 )}41 {...props}42 />43 )44}4546export { Input }4748export type InputProps = React.ComponentProps<typeof Input>
What it pulls in
npm packages
Other registry items
Files it writes
More from @nswds/ui
All 46 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Aspect Ratioaspect-ratio | @nswds/ui | Components | Free | 2 deps · 2 files | |
| Badgebadge | @nswds/ui | Components | Free | 4 deps · 2 files | |
| Buttonbutton | @nswds/ui | Components | Free | 4 deps · 2 files | |
| Cardcard | @nswds/ui | Components | Free | 2 deps · 2 files | |
| Collapsiblecollapsible | @nswds/ui | Components | Free | 1 dep | |
| Drawerdrawer | @nswds/ui | Components | Free | 3 deps · 2 files | |
| Expandable Searchexpandable-search | @nswds/ui | Components | Free | 3 deps · 2 files | |
| Fieldfield | @nswds/ui | Components | Free | 4 deps · 2 files |
