Kumo Svelte
  • Home
  • Installation
  • Colors
  • Accessibility
  • Changelog
  • Autocomplete
  • Badge
  • Banner
  • Breadcrumbs
  • Button
  • Checkbox
  • Clipboard Text
  • Cloudflare Logo
  • CodeHighlighted
  • Collapsible
  • Combobox
  • Command Palette
  • Date Picker
  • Dialog
  • Dropdown
  • Empty
  • Flow
  • Grid
  • Input
  • InputArea
  • InputGroup
  • Label
  • Layer Card
  • Link
  • Loader
  • MenuBar
  • Meter
  • Pagination
  • Popover
  • Radio
  • Select
  • Sensitive Input
  • Sidebar
  • Skeleton Line
  • Switch
  • Table
  • Table of Contents
  • Tabs
  • Text
  • Toast
  • Toolbar
  • Tooltip
  • Charts
  • Colors
  • Timeseries
  • Maps
  • Sankey
  • Custom Chart
  • Page Header
  • Resource List
  • Delete Resource
Input
kumo-svelte

Input

A text input field for user input with built-in label, description, and error support.

We'll never share your email

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

<Input label="Email" placeholder="you@example.com" description="We'll never share your email" />

Import

import { Input } from "kumo-svelte/components/input";

Usage

With Built-in Field (Recommended)

Use the label prop to enable the built-in Field wrapper with label, description, and error support.

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

<Input
  label="Email"
  placeholder="you@example.com"
  description="We'll never share your email"
/>

Bare Input (Custom Layouts)

For custom form layouts, use Input without label. Provide aria-label or aria-labelledby for accessibility.

<Input placeholder="Search..." aria-label="Search products" />

Examples

With Label and Description

The label prop enables the built-in Field wrapper with automatic vertical layout.

3-20 characters, alphanumeric only

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

<Input label="Username" placeholder="Choose a username" description="3-20 characters, alphanumeric only" />

With Error (String)

Pass error as a string for simple error messages. Error styling is automatically applied when the error prop is truthy.

Please enter a valid email address

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

<Input label="Email" placeholder="you@example.com" value="invalid-email" error="Please enter a valid email address" />

With Error (Validation Object)

Pass error to show validation copy and the error visual state. The component API also supports validity-matched error objects.

Password must be at least 8 characters

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

<Input
  label="Password"
  type="password"
  value="short"
  error="Password must be at least 8 characters"
  minlength={8}
/>

Input Sizes

Four sizes available: xs, sm, base (default), and lg.

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

<div class="flex flex-col gap-4">
  <Input size="xs" label="Extra Small" placeholder="Extra small input" />
  <Input size="sm" label="Small" placeholder="Small input" />
  <Input label="Base" placeholder="Base input (default)" />
  <Input size="lg" label="Large" placeholder="Large input" />
</div>

Disabled

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

<Input label="Disabled field" placeholder="Cannot edit" disabled />

Optional Field

Set required={false} to show optional text after the label.

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

<Input label="Phone Number" required={false} placeholder="+1 (555) 000-0000" />

With Label Tooltip

Use labelTooltip to add an info icon with additional context on hover.

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

{#snippet labelTooltip()}
  Find this in your dashboard under Settings &gt; API Keys
{/snippet}

<Input label="API Key" {labelTooltip} placeholder="sk_live_..." />

Snippet Label

The label prop accepts a string or snippet for rich formatting.

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

{#snippet label()}
  <span>Email for <strong>billing</strong></span>
{/snippet}

<Input label={label} required placeholder="billing@company.com" type="email" />

Controlled with oninput

Use the standard Svelte oninput handler when you need the native input event.

Uses event.currentTarget.value

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
  let value = $state("");
</script>

<Input
  label="With oninput"
  placeholder="Type something..."
  description={value ? `Value: ${value}` : "Uses event.currentTarget.value"}
  {value}
  oninput={(event) => {
    value = event.currentTarget.value;
  }}
/>

Controlled with bind:value

Use bind:value for idiomatic Svelte two-way state.

Uses Svelte two-way binding

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
  let value = $state("");
</script>

<Input
  label="With bind:value"
  placeholder="Type something..."
  description={value ? `Value: ${value}` : "Uses Svelte two-way binding"}
  bind:value
/>

Bare Input (No Label)

Input without label renders as a bare input. Provide aria-label for accessibility.

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

<Input placeholder="Search..." aria-label="Search products" />

Error Without Label

Error messages and descriptions render even without a visible label; use aria-label to keep the input accessible.

Please enter a valid hostname

Path must start with /

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

<div class="flex flex-col gap-4">
  <Input aria-label="Hostname" placeholder="example.com" value="not a host" error="Please enter a valid hostname" />
  <Input aria-label="Path" placeholder="/api/v1/users" value="missing-slash" error="Path must start with /" />
</div>

Input Types

Supports standard HTML input types: text, email, password, number, tel, url, and more.

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

<div class="flex flex-col gap-4">
  <Input type="email" label="Email" placeholder="you@example.com" />
  <Input type="password" label="Password" placeholder="••••••••" />
  <Input type="number" label="Age" placeholder="18" />
  <Input type="tel" label="Phone" placeholder="+1 (555) 000-0000" />
</div>

Password Manager Ignore

Set passwordManagerIgnore to add common password-manager ignore attributes.

<script lang="ts">
  import { Input } from "kumo-svelte/components/input";
</script>

<div class="flex flex-col gap-4">
  <Input label="API Key (default)" type="password" placeholder="sk_live_..." />
  <Input label="API Key (passwordManagerIgnore)" type="password" placeholder="sk_live_..." passwordManagerIgnore />
</div>

API Reference

Input

PropTypeDefault
descriptionSnippet | string—
errorstring | { message: Snippet | string; match: FieldErrorMatch }—
labelSnippet | string—
labelTooltipSnippet—
passwordManagerIgnorebooleanfalse
sizeKumoInputSizeKUMO_INPUT_DEFAULT_VARIANTS.size
valuestring | number | string[] | undefinedbindable
variantKumoInputVariant—

On this page

  • Import
  • Usage
    • With Built-in Field (Recommended)
    • Bare Input (Custom Layouts)
  • Examples
    • With Label and Description
    • With Error (String)
    • With Error (Validation Object)
    • Input Sizes
    • Disabled
    • Optional Field
    • With Label Tooltip
    • Snippet Label
    • Controlled with oninput
    • Controlled with bind:value
    • Bare Input (No Label)
    • Error Without Label
    • Input Types
    • Password Manager Ignore
  • API Reference
    • Input