ki-prompt-input
@kimen/elements/ki-prompt-input- Source
- Agent reference
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.
<ki-prompt-inputlabel="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
| Attribute | Property | Type | Default | Description |
|---|---|---|---|---|
accept | accept | string | undefined | '' | Comma-separated extensions or MIME types. Empty hides the attachment surface. |
attach-label | attachLabel | string | 'Attach files' | Accessible name of the file picker button. |
attachments-label | attachmentsLabel | string | 'Attachments' | Accessible name of the attachment list. |
disabled | disabled | boolean | false | Excludes the composer from interaction and native form data. |
file-count-message | fileCountMessage | string | '{name} exceeds the maximum number of attachments.' | Localized count rejection. The {name} marker is replaced with the file name. |
file-size-message | fileSizeMessage | string | '{name} exceeds the file size limit.' | Localized size rejection. The {name} marker is replaced with the file name. |
file-type-message | fileTypeMessage | string | '{name} has an unsupported file type.' | Localized type rejection. The {name} marker is replaced with the file name. |
label | label | string | – | Required accessible name of the text field. Supply it even with a placeholder. |
max-files | maxFiles | number | undefined | – | Maximum count of attached files. Omit for no count limit. |
max-size | maxSize | number | undefined | – | Maximum attachment size in bytes per file. Omit for no size limit. |
name | name | string | undefined | – | Optional key for the text in native form data. Files are carried by ki-submit. |
placeholder | placeholder | string | undefined | – | Hint displayed while the text field is empty. |
remove-label | removeLabel | string | 'Remove' | Prefix of an attachment's remove button name, followed by the file name. |
send-label | sendLabel | string | 'Send' | Accessible name of the Send button. |
status | status | "idle" | "streaming" | "submitted" | undefined | 'idle' | Application-owned request state. Only idle can send; streaming exposes Stop. |
stop-label | stopLabel | string | 'Stop generating' | Accessible name of the Stop button. |
submit-on | submitOn | "enter" | "mod-enter" | 'enter' | Send with Enter or with Control/Command+Enter. Shift+Enter always adds a line. |
value | value | string | undefined | '' | Current draft text; the value attribute provides the form reset default. |
writing-message | writingMessage | string | 'Writing…' | Visible polite status while the assistant streams. |
Events
| Event | Detail type | Description |
|---|---|---|
ki-stop | CustomEvent<void> | Requests that the application stop its streaming response. |
ki-submit | CustomEvent<KiPromptInputSubmitDetail> | Requests a send with original text and a snapshot of accepted local files. |
Slots
| Slot | Description |
|---|---|
attachments | Supplemental list items, visible when accept is set. Composer-managed files appear in the same list and alone contribute to ki-submit. |
tools | Application-owned toolbar controls, such as a model-picker trigger. Use non-submitting controls. |
CSS parts
| Part | Description |
|---|---|
actions | The toolbar with attachment, tool and message actions. |
attach | The native file-picker button. |
attachments | The labelled attachment list. |
feedback | The polite announcement for rejected attachments. |
field | The painted composer enclosure. |
send | The native Send button. |
status | The polite announcement for the streaming state. |
stop | The native Stop button, visible while streaming. |
textarea | The native growing text control. |
tools | The 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.
| Token | Description |
|---|---|
--ki-button-ghost-neutral-hover-bg | color used by the button component for ghost neutral hover background. |
--ki-button-ghost-neutral-hover-fg | color used by the button component for ghost neutral hover foreground. |
--ki-button-ghost-neutral-rest-bg | color used by the button component for ghost neutral rest background. |
--ki-button-ghost-neutral-rest-fg | color used by the button component for ghost neutral rest foreground. |
--ki-button-primary-neutral-disabled-bg | color 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-border | color used by the button component for primary neutral disabled border. |
--ki-button-primary-neutral-disabled-fg | color 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-bg | color used by the button component for primary neutral rest background (MarsUI Surface/primary_med_em, brand 500). |
--ki-button-primary-neutral-rest-border | color used by the button component for primary neutral rest border (MarsUI bevel top/inline edge). |
--ki-button-primary-neutral-rest-fg | color used by the button component for primary neutral rest foreground. |
--ki-button-secondary-neutral-rest-bg | color 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-border | color used by the button component for secondary neutral rest border (MarsUI bevel top/inline edge). |
--ki-button-secondary-neutral-rest-fg | color used by the button component for secondary neutral rest foreground (MarsUI text/high_em). |
--ki-button-sm-radius | dimension 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-sm | Small control track height, 32 CSS px at the default root size. |
--ki-density-control-offset | Added 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-scale | Multiplies every scaled container padding and gap (card, dialog, alert, list, list item, select listbox, tab panel, tooltip). |
--ki-density-target-min | The 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-color | Colour of the keyboard focus ring every focusable component draws: 3:1 or more against the page in every theme and scheme. |
--ki-focus-ring-offset | Gap between a focusable component and its keyboard focus ring. |
--ki-focus-ring-width | Thickness 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-size | dimension used by the icon button component for sm icon size (MarsUI Placeholder_sm 18px). |
--ki-prompt-input-action-gap | Default spacing between attachments and toolbar controls. |
--ki-prompt-input-backdrop-filter | Optional whole backdrop filter behind the composer. |
--ki-prompt-input-bg | Raised surface behind the prompt composer. |
--ki-prompt-input-bg-image | Optional background image painted above the composer surface. |
--ki-prompt-input-border | Outline around the composer. |
--ki-prompt-input-border-width | Outline thickness around the composer. |
--ki-prompt-input-editor-padding-block | Block inset for the native text field and its sizer. |
--ki-prompt-input-editor-padding-inline | Inline inset for the native text field and its sizer. |
--ki-prompt-input-feedback-bg | Surface immediately behind attachment rejection text. |
--ki-prompt-input-feedback-fg | Attachment rejection text on the composer surface. |
--ki-prompt-input-fg | Draft text on the composer surface. |
--ki-prompt-input-max-height | Maximum height of the draft before the textarea scrolls. |
--ki-prompt-input-min-height | Minimum height of the editable draft. |
--ki-prompt-input-padding | Inset and spacing between rows in the composer. |
--ki-prompt-input-placeholder-fg | Placeholder and writing status on the composer surface. |
--ki-prompt-input-radius | Corner radius of the composer surface. |
--ki-typography-family-body | semantic font family for typography family body. |
--ki-typography-line-height-body-2 | semantic dimension for typography line height body 2. |
--ki-typography-line-height-caption-2 | semantic dimension for typography line height caption 2. |
--ki-typography-size-body-2 | semantic dimension for typography size body 2. |
--ki-typography-size-caption-2 | semantic dimension for typography size caption 2. |