Skip to content

Input

User input collection.


Purpose

Text fields, file uploads, voice input — collect user input for AI processing.

Use <input> when the interface needs to gather structured user responses inside the same Grain document that displays assistant output and approval checkpoints.


G-Lang

grain
<input type="text" placeholder="Ask me anything..." multiline="true">
  <suggestion>Explain quantum computing</suggestion>
  <suggestion>Write a Python script</suggestion>
</input>

Attributes

AttributeTypeDescription
typetext | file | image | voice | multimodalInput type
placeholderstringPlaceholder text
autofocustrue | falseAuto-focus on mount
maxlengthnumberCharacter limit
multilinetrue | falseTextarea
attachmentstrue | falseAllow file attachments
voicetrue | falseEnable voice input

Nested

<suggestion> — Quick suggestions

grain
<suggestion>Explain AI</suggestion>
<suggestion>Write code</suggestion>

States

EMPTY → TYPING → FILLED → SUBMITTING → SUBMITTED

Events

EventDescription
input.focusInput gained focus
input.changeValue changed
input.submitForm submitted
input.voice.startVoice recording started
input.suggestion.clickUser clicked suggestion

Usage Notes

  • Keep the type aligned with the actual interaction surface so web, CLI, and other adapters can degrade gracefully.
  • Use <suggestion> for common follow-ups rather than burying example prompts in surrounding prose.
  • Pair <input> with <context> when the user may attach files, URLs, or prior memory.

Released under the MIT License.