Skip to content
Kimenpre-v1documentation home
Color scheme

ki-prompt-input

Use <ki-prompt-input> to compose assistant messages. Give every composer a label so its native textarea has an accessible name. The draft grows until --ki-prompt-input-max-height and then scrolls.

Theme for this example
Color scheme for this example
<ki-prompt-input
label="Message Kimen Assistant"
placeholder="Ask anything, or drop a file"
accept=".csv,.pdf,image/*"
max-files="5"
max-size="5000000"
></ki-prompt-input>

Sending and stopping

Listen for ki-submit on the composer. Its detail contains the original text and the local files. The composer clears the sent draft and focuses the textarea. Set status to submitted while waiting and streaming when the assistant begins writing. Handle ki-stop to stop the response and return to idle when it finishes. The writing message is announced politely.

Enter sends by default. With submit-on="mod-enter", use Control+Enter or Command+Enter. Shift+Enter always adds a line.

Tools and files

Place an application-owned model picker or another action in tools. Use a button with type="button" when the composer is inside a form. When accept is set, the picker, drop, and paste can attach local files. max-size is bytes per file. Use the attachments slot for supplemental <li> elements in the labelled list. Files from the picker, drop, and paste appear as removable chips.

A named composer contributes its text to an enclosing form. Use ki-submit to read files. In a guarded Kimen surface, one declared action handles both requests. The action data includes status and the current draft value. Local files are available on the DOM event.

API reference

When to use: Compose a message to an assistant, optionally attach local files, and let people interrupt the assistant's response.

When not to use: Ordinary multiline form input without a send or stop interaction (ki-textarea), file uploads, or rich text editing.

Properties & attributes

AttributePropertyTypeDefaultDescription
acceptacceptstring | undefined''Comma-separated extensions or MIME types. Empty hides the attachment surface.
attach-labelattachLabelstring'Attach files'Accessible name of the file picker button.
attachments-labelattachmentsLabelstring'Attachments'Accessible name of the attachment list.
disableddisabledbooleanfalseExcludes the composer from interaction and native form data.
file-count-messagefileCountMessagestring'{name} exceeds the maximum number of attachments.'Localized count rejection. The {name} marker is replaced with the file name.
file-size-messagefileSizeMessagestring'{name} exceeds the file size limit.'Localized size rejection. The {name} marker is replaced with the file name.
file-type-messagefileTypeMessagestring'{name} has an unsupported file type.'Localized type rejection. The {name} marker is replaced with the file name.
labellabelstring–Required accessible name of the text field. Supply it even with a placeholder.
max-filesmaxFilesnumber | undefined–Maximum count of attached files. Omit for no count limit.
max-sizemaxSizenumber | undefined–Maximum attachment size in bytes per file. Omit for no size limit.
namenamestring | undefined–Optional key for the text in native form data. Files are carried by ki-submit.
placeholderplaceholderstring | undefined–Hint displayed while the text field is empty.
remove-labelremoveLabelstring'Remove'Prefix of an attachment's remove button name, followed by the file name.
send-labelsendLabelstring'Send'Accessible name of the Send button.
statusstatus"idle" | "streaming" | "submitted" | undefined'idle'Application-owned request state. Only idle can send; streaming exposes Stop.
stop-labelstopLabelstring'Stop generating'Accessible name of the Stop button.
submit-onsubmitOn"enter" | "mod-enter"'enter'Send with Enter or with Control/Command+Enter. Shift+Enter always adds a line.
valuevaluestring | undefined''Current draft text; the value attribute provides the form reset default.
writing-messagewritingMessagestring'Writing…'Visible polite status while the assistant streams.

Events

EventDetail typeDescription
ki-stopCustomEvent<void>Requests that the application stop its streaming response.
ki-submitCustomEvent<KiPromptInputSubmitDetail>Requests a send with original text and a snapshot of accepted local files.

Slots

SlotDescription
attachmentsSupplemental list items, visible when accept is set. Composer-managed files appear in the same list and alone contribute to ki-submit.
toolsApplication-owned toolbar controls, such as a model-picker trigger. Use non-submitting controls.

CSS parts

PartDescription
actionsThe toolbar with attachment, tool and message actions.
attachThe native file-picker button.
attachmentsThe labelled attachment list.
feedbackThe polite announcement for rejected attachments.
fieldThe painted composer enclosure.
sendThe native Send button.
statusThe polite announcement for the streaming state.
stopThe native Stop button, visible while streaming.
textareaThe native growing text control.
toolsThe container for the tools slot.

CSS custom properties

The public styling contract of ki-prompt-input: reassign these tokens at :root or on a subtree — never override internals.

TokenDescription
--ki-button-ghost-neutral-hover-bgcolor used by the button component for ghost neutral hover background.
--ki-button-ghost-neutral-hover-fgcolor used by the button component for ghost neutral hover foreground.
--ki-button-ghost-neutral-rest-bgcolor used by the button component for ghost neutral rest background.
--ki-button-ghost-neutral-rest-fgcolor used by the button component for ghost neutral rest foreground.
--ki-button-primary-neutral-disabled-bgcolor used by the button component for primary neutral disabled background. Deliberate deviation: Figma disabled is Surface/disabled_base_em gray.100 with gray.400 text (≈1.4:1); Kimen keeps gray.200 for contrast (precedent 010 D2, pending founder ratification).
--ki-button-primary-neutral-disabled-bordercolor used by the button component for primary neutral disabled border.
--ki-button-primary-neutral-disabled-fgcolor used by the button component for primary neutral disabled foreground. Deliberate deviation: Figma disabled text is text/base_em gray.400 (≈1.4:1 on gray.100); Kimen keeps text.muted gray.700 for readable disabled text (precedent 010 D2, pending founder ratification).
--ki-button-primary-neutral-rest-bgcolor used by the button component for primary neutral rest background (MarsUI Surface/primary_med_em, brand 500).
--ki-button-primary-neutral-rest-bordercolor used by the button component for primary neutral rest border (MarsUI bevel top/inline edge).
--ki-button-primary-neutral-rest-fgcolor used by the button component for primary neutral rest foreground.
--ki-button-secondary-neutral-rest-bgcolor used by the button component for secondary neutral rest background (MarsUI Surface/special/secondary_alpha_base: gray glass, not a brand tint).
--ki-button-secondary-neutral-rest-bordercolor used by the button component for secondary neutral rest border (MarsUI bevel top/inline edge).
--ki-button-secondary-neutral-rest-fgcolor used by the button component for secondary neutral rest foreground (MarsUI text/high_em).
--ki-button-sm-radiusdimension used by the button component for sm radius (Button master 8003:300 binds Radius/small-component/sm, the scale a radius mode reassigns).
--ki-control-size-smSmall control track height, 32 CSS px at the default root size.
--ki-density-control-offsetAdded to the block size of every scaled control and row (button, icon button, field, select, textarea, option, list item, tab). Components floor the result at ki.size.target-min.
--ki-density-space-scaleMultiplies every scaled container padding and gap (card, dialog, alert, list, list item, select listbox, tab panel, tooltip).
--ki-density-target-minThe smallest pointer target any density may produce: 24 x 24 CSS px by default and in compact (WCAG 2.5.8 AA), 44 x 44 in touch (WCAG 2.5.5). It floors a shrinking control but never lifts what a control paints: a control painted smaller extends its target to it, invisibly; rows and tabs grow to it (spec 045 A1).
--ki-focus-ring-colorColour of the keyboard focus ring every focusable component draws: 3:1 or more against the page in every theme and scheme.
--ki-focus-ring-offsetGap between a focusable component and its keyboard focus ring.
--ki-focus-ring-widthThickness of the keyboard focus ring every focusable component draws (its outline). One token instead of one per component, so a mode or a theme changes every ring at once.
--ki-icon-button-sm-icon-sizedimension used by the icon button component for sm icon size (MarsUI Placeholder_sm 18px).
--ki-prompt-input-action-gapDefault spacing between attachments and toolbar controls.
--ki-prompt-input-backdrop-filterOptional whole backdrop filter behind the composer.
--ki-prompt-input-bgRaised surface behind the prompt composer.
--ki-prompt-input-bg-imageOptional background image painted above the composer surface.
--ki-prompt-input-borderOutline around the composer.
--ki-prompt-input-border-widthOutline thickness around the composer.
--ki-prompt-input-editor-padding-blockBlock inset for the native text field and its sizer.
--ki-prompt-input-editor-padding-inlineInline inset for the native text field and its sizer.
--ki-prompt-input-feedback-bgSurface immediately behind attachment rejection text.
--ki-prompt-input-feedback-fgAttachment rejection text on the composer surface.
--ki-prompt-input-fgDraft text on the composer surface.
--ki-prompt-input-max-heightMaximum height of the draft before the textarea scrolls.
--ki-prompt-input-min-heightMinimum height of the editable draft.
--ki-prompt-input-paddingInset and spacing between rows in the composer.
--ki-prompt-input-placeholder-fgPlaceholder and writing status on the composer surface.
--ki-prompt-input-radiusCorner radius of the composer surface.
--ki-typography-family-bodysemantic font family for typography family body.
--ki-typography-line-height-body-2semantic dimension for typography line height body 2.
--ki-typography-line-height-caption-2semantic dimension for typography line height caption 2.
--ki-typography-size-body-2semantic dimension for typography size body 2.
--ki-typography-size-caption-2semantic dimension for typography size caption 2.

Workshop

Open PromptInput in Storybook