Smart input

Text, voice or photo fills your zod form on device, with per-field confidence, deterministic refinement and confirm/undo.

Mock· scripted answersNo model runs in a browser, so every answer here is scripted. On a phone it comes from the model.
  • Apple Foundation Models: supported
  • Gemini Nano: supported
  • Llama (not yet supported): not supported
  • A cloud model: supported

Install

npx ondai add smart-input

Usage

import { SmartInput } from '@/components/ondai/smart-input'
import { z } from 'zod'

const expense = z.object({
  merchant: z.string(),
  amount: z.number(),
  category: z.enum(['food', 'transport', 'home', 'other']),
  date: z.string().describe('date').optional(),
})

<SmartInput schema={expense} presentation="field" onFill={(values) => form.reset(values)} aliases={{ category: { food: ['lunch', 'dinner'] } }} />
  • Enums are fuzzy-matched, numbers and money parsed, dates resolved from phrases ("yesterday") in code after the model answers.
  • Per-field confidence drives highlight / badge / underline styles and confirm/undo.
  • For react-hook-form: form.apply((name, value) => setValue(name, value)).

Customize

Every AI component takes the same look and customization props, so it fits your app rather than ours.

<SmartInput
  variant="pop"
  tint="#FF5A5F"
  size="lg"
  radius={12}
  icons={{ input: Search, voice: null }}
  labels={{ placeholder: '…', thinking: '…' }}
/>
PropWhat it does
variantThe look of the whole component: clean, minimal, glass, pop, candy, metal, shine
sizesm, md, lg; type, rows, icons and keys scale together
tintAny colour; the variant paints its keys, tiles and glow in it
radiusCorner radius of the container
iconsReplace any icon (a lucide component, an element, or null to hide it): input, voice, camera, submit, filled, confirm, undo, error
labelsEvery visible and spoken string; defaults are exported as smartInputLabels: placeholder, thinking, fill, submit, voice, camera, filledCount, undo, undoAll, use, confirm, add, filledMark, retry
SlotsDraw a part yourself: renderField, renderSubmit, renderEmpty, renderFooter
stylesStyle any named part

Variants

PropOptions
variantclean, minimal, glass, pop, candy, metal, shine
presentationfield, composer, overlay, card
sizesm, md, lg
confidenceStylehighlight, badge, underline

Token budget

Input budget: 1500 tokens. One structured call; enum/number/date fields are refined deterministically after parsing.

Fallback

When no provider is ready the component renders the unavailable state (AvailabilityGate copy) and, where a deterministic path exists, keeps working without the model.

Eval score

Fixtures: evals/smart-input/fixtures.json.

Files

Registry dependencies: button, chip, ion-border, on-device-badge, shimmer-text, skeleton, surface

npm dependencies: @ondai/core, @ondai/tokens, expo-haptics, lucide-react-native, react-native-reanimated, zod

On this page