Input
Text input field for user data entry. Supports various types, sizes, and states.
Installation
import { Input } from '@svelte-atoms/core/input';Why a Compound Component?
Input.Root styling without recreating it from scratch. For example, a dropdown trigger can look exactly like
an input by wrapping its content with Input.Root,
maintaining consistent styling across your application.Preset Configuration
Customize the input appearance using presets
You can customize the default styles for Input components by defining presets in your configuration:
The Input component uses a compound structure with separate preset keys for Root, Control, Icon, and Placeholder.
Examples
Explore different input variations
Basic Input
Simple text input
<Input.Root> <Input.Control placeholder="Enter text..." /> </Input.Root>
Input Types
Different input types for various data
<Input.Root> <Input.Control type="text" placeholder="Text input" /> </Input.Root> <Input.Root> <Input.Control type="email" placeholder="Email input" /> </Input.Root> <Input.Root> <Input.Control type="password" placeholder="Password input" /> </Input.Root> <Input.Root> <Input.Control type="number" placeholder="Number input" /> </Input.Root>
Input with Icons
Add icons or text decorations around the input
<Input.Root> <Input.Icon>$</Input.Icon> <Input.Control placeholder="0.00" /> <Input.Icon>.00</Input.Icon> </Input.Root>
Input with Placeholder
Custom placeholder component that disappears when input has value
<Input.Root> <Input.Control /> <Input.Placeholder>Enter your email...</Input.Placeholder> </Input.Root>
Controlled Input
Bind input value to state
You typed: (nothing yet)
<script lang="ts">
let value = $state('');
</script>
<Input.Root>
<Input.Control bind:value />
</Input.Root>
<p>You typed: {value}</p>API Reference
Input.Root
Container component that manages input state and context.
Input.Control
The actual input element.
Input.Icon
Icon or text decoration component.
Input.Placeholder
Custom placeholder component that automatically hides when input has value.