Forms

Input

Capture user text input with a flexible, accessible input field. Supports variants, colors, icons, avatars, loading states, and highlights.

Playground

Experiment with different props in real-time.

Basic Usage

Import and use the Input component with a placeholder prop.

<script lang="ts">
  import { Input } from 'sv5ui';
</script>

<Input placeholder="Enter text..." />

Variants

5 visual styles for different contexts and emphasis levels.

<Input variant="outline" placeholder="Outline" />
<Input variant="none" placeholder="None" />
<Input variant="soft" placeholder="Soft" />
<Input variant="subtle" placeholder="Subtle" />
<Input variant="ghost" placeholder="Ghost" />

Sizes

5 sizes from extra small to extra large.

<Input size="xs" placeholder="Extra Small" />
<Input size="sm" placeholder="Small" />
<Input size="md" placeholder="Medium" />
<Input size="lg" placeholder="Large" />
<Input size="xl" placeholder="Extra Large" />

Colors

Semantic color schemes to match your design context.

<Input color="primary" placeholder="Primary" />
<Input color="secondary" placeholder="Secondary" />
<Input color="tertiary" placeholder="Tertiary" />
<Input color="success" placeholder="Success" />
<Input color="warning" placeholder="Warning" />
<Input color="error" placeholder="Error" />
<Input color="info" placeholder="Info" />

With Icons

Add leading and trailing icons using Iconify names.

<!-- Leading icon (shorthand) -->
<Input icon="lucide:search" placeholder="Search..." />

<!-- Leading icon (explicit) -->
<Input leadingIcon="lucide:mail" placeholder="Email" />

<!-- Trailing icon -->
<Input trailingIcon="lucide:eye" placeholder="Password" type="password" />

<!-- Both icons -->
<Input leadingIcon="lucide:link" trailingIcon="lucide:copy" placeholder="https://example.com" />

With Avatar

Display an avatar in the leading position using the avatar prop.

U
<Input
  avatar={{ src: 'https://i.pravatar.cc/40', alt: 'User' }}
  placeholder="What's on your mind?"
/>

Loading

Show a loading spinner inside the input.

<Input loading placeholder="Loading..." />

Highlight

Add a colored highlight ring to draw attention to the input.

<Input highlight placeholder="Highlighted input" />
<Input highlight color="error" placeholder="Error highlight" />

Disabled

Prevent user interaction with the disabled state.

<Input disabled placeholder="Disabled input" />
<Input disabled value="Cannot edit this" />

Types

Support for various HTML input types.

<Input type="text" placeholder="Text" />
<Input type="password" placeholder="Password" />
<Input type="number" placeholder="Number" />
<Input type="email" placeholder="Email address" />

UI Slots

Use the ui prop to override classes on specific internal elements of the Input.

SlotDescription
rootOutermost wrapper element — controls overall layout and spacing
baseInner input element — controls shape, padding, typography
leadingLeading content wrapper — controls leading area layout
leadingIconIcon before the input — controls icon size, color
leadingAvatarAvatar before the input — controls avatar wrapper styles
leadingAvatarSizeAvatar size override — controls avatar dimensions
trailingTrailing content wrapper — controls trailing area layout
trailingIconIcon after the input — controls icon size, color
<Input
  placeholder="Custom styled"
  leadingIcon="lucide:search"
  ui={{
    base: 'rounded-full',
    leadingIcon: 'text-primary'
  }}
/>

Snippets

Use snippets to fully replace the leading or trailing content with custom markup.

SnippetReplacesDescription
leadingSlotleadingIcon / avatarCustom content before the input — replaces icon and avatar
trailingSlottrailingIconCustom content after the input — replaces trailing icon
https://
<Input placeholder="example.com" ui={{ base: 'ps-18' }}>
  {#snippet leadingSlot()}
    <span class="border-r border-on-surface/15 pr-2 text-xs font-medium text-on-surface/50">https://</span>
  {/snippet}
  {#snippet trailingSlot()}
    <Button size="xs" variant="solid" color="primary" label="Go" />
  {/snippet}
</Input>

Props

PropTypeDefault
refHTMLInputElement-
valuestring-
typestring'text'
variant'none' | 'outline' | 'soft' | 'subtle' | 'ghost''outline'
colorColor'primary'
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
highlightbooleanfalse
loadingbooleanfalse
loadingIconstringicons.loading
disabledbooleanfalse
iconstring-
leadingIconstring-
trailingIconstring-
trailingbooleanfalse
avatarAvatarProps-
placeholderstring-
idstring-
namestring-
classstring-
uiRecord<Slot, Class>-