s-m-r-t

TextInput

A Material Design 3 inspired text input with optional voice input support in smrt mode. Supports text and email types with built-in validation.

Installation

typescript
import { TextInput } from '@happyvertical/smrt-svelte';

Basic Usage

The simplest text input with a label and bindable value.

svelte
<script lang="ts">
  let value = $state('');
</script>

<TextInput
  name="username"
  label="Username"
  bind:value
/>

Email Type

Use type="email" for built-in email validation.

svelte
<TextInput
  name="email"
  label="Email Address"
  type="email"
  placeholder="you@example.com"
  bind:value
/>

Required Field

Add required to mark the field as required (shows an asterisk).

svelte
<TextInput
  name="fullName"
  label="Full Name"
  required
  bind:value
/>

Disabled State

Use disabled to prevent user interaction.

svelte
<TextInput
  name="disabled"
  label="Disabled Field"
  value="Cannot edit this"
  disabled
/>

With Description

Add a description for context, shown when the field is focused. Also used by AI for voice extraction.

svelte
<TextInput
  name="bio"
  label="Short Bio"
  description="A brief description about yourself"
  placeholder="Tell us about yourself..."
/>

Voice Input (smrt Mode)

When the application is in smrt mode, a microphone button appears. Users can hold to speak and the input will be processed via speech-to-text. The appendMode prop controls whether spoken text replaces or appends to existing content.

svelte
<!-- In smrt mode, this input shows a mic button -->
<TextInput
  name="notes"
  label="Notes"
  appendMode
  description="Any additional notes"
/>

Interactive Example

Type in the field to see the bound value update:

Current value: (empty)

svelte
<script lang="ts">
  let value = $state('');
</script>

<TextInput
  name="interactive"
  label="Type something"
  bind:value
/>
<p>Current value: {value || '(empty)'}</p>

Props

PropTypeDefaultDescription
name *string-Field name for form submission
label stringundefinedField label displayed above the input
description stringundefinedDescription text for LLM field extraction
type 'text' | 'email''text'Input type - text or email with validation
placeholder string''Placeholder text shown when empty
value string''Current value (bindable)
disabled booleanfalseDisables the input
required booleanfalseMarks field as required
appendMode booleanfalseAppend to existing value instead of overwriting (for voice input)
onchange (value: string) => voidundefinedCallback when value changes

TypeScript

typescript
import { TextInput } from '@happyvertical/smrt-svelte';

// Props interface
interface Props {
  name: string;
  label?: string;
  description?: string;
  type?: 'text' | 'email';
  placeholder?: string;
  value?: string;
  disabled?: boolean;
  required?: boolean;
  appendMode?: boolean;
  onchange?: (value: string) => void;
}