Skip to main content
Urbicon UI

Input

Text input fields with validation states, icons, and form integration.

Playground

We will never share your email
Variant Style variant (tailwind-variants)
Intent Style variant (tailwind-variants)
Tier Style variant (tailwind-variants)
<Input
  error=""
  helper="We will never share your email"
  label="Email"
  placeholder="name@example.com"
/>

01 Examples

Search input

Pair clearable with a left search icon — the most common real-world pattern. Press Escape or click the clear button to reset.
<Input
  clearable
  bind:value={searchValue}
  placeholder="Search anything..."
  aria-label="Search"
>
  {#snippet leftIcon()}
    <SearchIcon />
  {/snippet}
</Input>

Password with visibility toggle

Combine type='password' with a clickable right icon — onRightIconClick turns the icon into an accessible button (note the required rightIconAriaLabel).
<Input
  type={passwordVisible ? 'text' : 'password'}
  label="Password"
  placeholder="Enter your password"
  bind:value={passwordValue}
  onRightIconClick={() => (passwordVisible = !passwordVisible)}
  rightIconAriaLabel={passwordVisible ? 'Hide password' : 'Show password'}
>
  {#snippet leftIcon()}
    <LockIcon />
  {/snippet}
  {#snippet rightIcon()}
    {#if passwordVisible}
      <EyeOffIcon />
    {:else}
      <EyeIcon />
    {/if}
  {/snippet}
</Input>

Email field with validation error

error overrides helper and forces danger styling regardless of intent. Combined with a left icon for visual context.
<Input
  type="email"
  label="Email"
  placeholder="name@example.com"
  value="not-an-email"
  error="Please enter a valid email address"
  required
>
  {#snippet leftIcon()}
    <MailIcon />
  {/snippet}
</Input>

02 Customization

Branded Search Bar

The container acts as the visual boundary with ring and shadow. The input's own border is suppressed via slotClasses.
<Input
  size="xl"
  placeholder="Search components, patterns, tokens..."
  clearable
  slotClasses={{
    container:
      'rounded-2xl bg-surface-base shadow-[var(--blocks-shadow-lg)] ring-2 ring-primary/20 focus-within:ring-primary/50 transition-all overflow-hidden',
    base: 'border-0 bg-transparent rounded-2xl focus-visible:ring-0'
  }}
/>

Glassmorphism Input

Frosted glass input for overlay or hero contexts.
<Input
  unstyled
  placeholder="Enter your email"
  slotClasses={{
    base: 'w-full rounded-xl border border-white/20 bg-white/10 px-5 py-3 text-white placeholder-white/50 shadow-lg backdrop-blur-md transition-all focus-visible:border-white/40 focus-visible:bg-white/15 focus-visible:outline-none'
  }}
/>

Underline Form

The underline variant pairs well with compact forms.
Optional
<Input variant="underline" label="Full Name" placeholder="Jane Doe" />
<Input variant="underline" label="Email" placeholder="jane@acme.com" />
<Input variant="underline" label="Phone" placeholder="+49 123 456 789" helper="Optional" />

Fully Custom (unstyled)

Drop all defaults for complete control.
<Input
  unstyled
  label="Brutalist Input"
  placeholder="Type something..."
  class="text-text-primary placeholder:text-text-tertiary w-full border-2 border-current bg-transparent px-4 py-3 font-mono text-sm focus-visible:outline-none"
  slotClasses={{
    label: 'font-mono text-xs uppercase tracking-widest text-text-secondary mb-1'
  }}
/>

A field treatment shared across forms belongs in a BlocksProvider preset (presets.Input) — register matching presets for Select and Textarea under the same name to keep the form language consistent. See Customization.

03 Accessibility

Built-in ARIA

Labels are automatically associated via for and id. Error and helper messages are linked through aria-describedby. Validation states set aria-invalid automatically.

Keyboard

Tab to focus. Native text input behavior for all key combinations. Clearable inputs respond to Escape to clear the value. Focus indication uses focus-visible: for keyboard-only visibility.

Color Contrast

Error, warning, and success states use both color and text to convey status – never color alone. Helper and error messages meet WCAG AA contrast ratios against all surface tokens.

04 API Reference

36 props
36 props
Prop
Type
Default
Description

05 Types

Local type definitions used by this component.

7 types
Name
Kind
Category
Used by
Description

06 Installation

Import

import { Input } from '@urbicon-ui/blocks';