Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Prompt Input

    AI chat composer. The field grows as you type, files attach as chips, Enter sends and Shift+Enter breaks a line, and the send button turns into stop.

    What should we build today?

    0/500

    What should we build today?

    0/500

    What should we build today?

    0/500

    What should we build today?

    0/500

    What should we build today?

    0/500
    @php
        $panel = 'grid gap-4';
        $title = 'text-center text-lg font-semibold text-ink';
    @endphp
    
    <div class="{{ $panel }}">
        <p class="{{ $title }}">What should we build today?</p>
        <x-markas.prompt-input
            :models="['Markas Pro', 'Markas Mini']"
            model="Markas Pro"
            :max-length="500"
            accept="image/*,.pdf"
        />
    </div>
    import { PromptInput } from "@/components/markas/PromptInput";
    
    const panel = "grid gap-4";
    const title = "text-center text-lg font-semibold text-ink";
    
    export default function PromptInputExample() {
      return (
        <div className={panel}>
          <p className={title}>What should we build today?</p>
          <PromptInput
            models={["Markas Pro", "Markas Mini"]}
            model="Markas Pro"
            maxLength={500}
            accept="image/*,.pdf"
          />
        </div>
      );
    }
    <script setup lang="ts">
    import PromptInput from "@/components/markas/PromptInput.vue";
    
    const panel = "grid gap-4";
    const title = "text-center text-lg font-semibold text-ink";
    </script>
    
    <template>
      <div :class="panel">
        <p :class="title">What should we build today?</p>
        <PromptInput
          :models="['Markas Pro', 'Markas Mini']"
          model="Markas Pro"
          :max-length="500"
          accept="image/*,.pdf"
        />
      </div>
    </template>
    <script lang="ts">
      import PromptInput from "$lib/components/markas/PromptInput.svelte";
    
      const panel = "grid gap-4";
      const title = "text-center text-lg font-semibold text-ink";
    </script>
    
    <div class={panel}>
      <p class={title}>What should we build today?</p>
      <PromptInput
        models={["Markas Pro", "Markas Mini"]}
        model="Markas Pro"
        maxLength={500}
        accept="image/*,.pdf"
      />
    </div>
    ---
    import PromptInput from "@/components/markas/PromptInput.astro";
    
    const panel = "grid gap-4";
    const title = "text-center text-lg font-semibold text-ink";
    ---
    
      <div class={panel}>
        <p class={title}>What should we build today?</p>
        <PromptInput models={['Markas Pro', 'Markas Mini']} model="Markas Pro" maxLength={500} accept="image/*,.pdf" />
      </div>
    import { Component } from "@angular/core";
    import { PromptInput } from "./markas/prompt-input.component";
    
    @Component({
      selector: "markas-example",
      imports: [PromptInput],
      template: `
        <div [class]="panel">
          <p [class]="title">What should we build today?</p>
          <markas-prompt-input
            [models]="['Markas Pro', 'Markas Mini']"
            model="Markas Pro"
            [maxLength]="500"
            accept="image/*,.pdf"
          />
        </div>
      `,
    })
    export default class PromptInputExample {
      protected readonly panel = "grid gap-4";
      protected readonly title = "text-center text-lg font-semibold text-ink";
    }

    Examples

    Generating with a stop button

    With tool toggles

    Compact reply box

    Rina Santoso

    Asked about order #INV-2041

    Can I pay the balance by bank transfer?

    Rina Santoso

    Asked about order #INV-2041

    Can I pay the balance by bank transfer?

    Rina Santoso

    Asked about order #INV-2041

    Can I pay the balance by bank transfer?

    Rina Santoso

    Asked about order #INV-2041

    Can I pay the balance by bank transfer?

    Rina Santoso

    Asked about order #INV-2041

    Can I pay the balance by bank transfer?

    Installation

    npx markasui@latest add prompt-input

    Usage

    <x-markas.prompt-input
        :models="['Markas Pro', 'Markas Mini']"
        model="Markas Pro"
        :max-length="2000"
        accept="image/*,.pdf"
        x-on:send="ask($event.detail.text, $event.detail.files); loading = true"
        x-on:stop="cancel(); loading = false"
    />
    import { PromptInput } from "@/components/markas/PromptInput";
    
    const [loading, setLoading] = useState(false);
    
    <PromptInput
      models={["Markas Pro", "Markas Mini"]}
      model="Markas Pro"
      maxLength={2000}
      loading={loading}
      onSend={({ text, files }) => {
        setLoading(true);
        ask(text, files).finally(() => setLoading(false));
      }}
      onStop={cancel}
    />;
    <script setup lang="ts">
    import PromptInput from "@/components/markas/PromptInput.vue";
    
    const model = ref("Markas Pro");
    const loading = ref(false);
    </script>
    
    <template>
      <PromptInput
        v-model:model="model"
        :models="['Markas Pro', 'Markas Mini']"
        :max-length="2000"
        :loading="loading"
        @send="({ text, files }) => ask(text, files)"
        @stop="cancel"
      >
        <template #actions>
          <button type="button" aria-pressed="false">Search</button>
        </template>
      </PromptInput>
    </template>
    <script lang="ts">
      import PromptInput from "$lib/components/markas/PromptInput.svelte";
    
      let text = $state("");
      let loading = $state(false);
    </script>
    
    <PromptInput
      bind:value={text}
      {loading}
      models={["Markas Pro", "Markas Mini"]}
      model="Markas Pro"
      onSend={({ text, files }) => (loading = true)}
      onStop={() => (loading = false)}
    />
    ---
    import PromptInput from "@/components/markas/PromptInput.astro";
    ---
    
    <PromptInput models={["Markas Pro", "Markas Mini"]} model="Markas Pro" />
    
    <script>
      const input = document.querySelector("markas-prompt-input");
      input?.addEventListener("send", () => input.toggleAttribute("loading", true));
      input?.addEventListener("stop", () => input.toggleAttribute("loading", false));
    </script>

    The bundled script dispatches send with { text, files } and stop on markas-prompt-input; set or remove its loading attribute to switch the button.

    import { Component, signal } from "@angular/core";
    import {
      PromptInput,
      type PromptInputValue,
    } from "./markas/prompt-input.component";
    
    @Component({
      selector: "app-chat",
      imports: [PromptInput],
      template: `
        <markas-prompt-input
          [(value)]="text"
          [loading]="loading()"
          [models]="['Markas Pro', 'Markas Mini']"
          model="Markas Pro"
          (send)="onSend($event)"
          (stop)="loading.set(false)"
        />
      `,
    })
    export class Chat {
      readonly text = signal("");
      readonly loading = signal(false);
      onSend(value: PromptInputValue) {
        this.loading.set(true);
      }
    }
    • The field grows with its content up to maxHeight, then scrolls. It uses CSS field-sizing and falls back to measuring in older browsers.
    • Enter sends, Shift+Enter adds a line. The text and the attached files are cleared after a send.
    • The send button is only active when there is text. While loading it becomes a stop button and fires stop.
    • In Blade the x-on handlers run inside the component, so loading = true in x-on:send switches it to the stop button.

    Props

    NameTypeDefaultDescription
    value / v-modelstring""Text in the field. React also takes defaultValue and onValueChange. Cleared after a send.
    onSend / @send / x-on:send(value: { text: string; files: File[] }) => void-Fires on Enter or the send button when there is text. Blade dispatches a send DOM event with { text, files } as detail.
    onStop / @stop / x-on:stop() => void-Fires when the stop button is pressed while loading.
    loadingbooleanfalseThe answer is being generated. The send button becomes a stop button and Enter no longer sends.
    maxLengthnumber-Character limit on the field. Shows a 12/500 counter that turns red at the limit.
    maxHeightnumber200Tallest the field grows, in px, before it scrolls.
    attachmentsbooleantrueShows the attach button. Picked files appear as chips with a remove button.
    acceptstring-File types for the hidden file input, such as image/*,.pdf.
    models(string | { value: string; label: string })[][]Options of the small native model picker on the left of the action row. Empty hides it.
    model / v-model:modelstring-Selected model. React reports changes with onModelChange, Blade fires the native change event.
    actionsReactNode / slot-Extra tools after the model picker, such as search or reasoning toggles. Blade and Vue use the actions slot.
    placeholderLabelstringAsk anythingPlaceholder of the field.
    inputLabelstringMessageAccessible name of the field.
    sendLabelstringSendAccessible name of the send button.
    stopLabelstringStopAccessible name of the button while loading.
    attachLabelstringAttach filesAccessible name of the attach button.
    removeLabelstringRemove {name}Accessible name of each chip's remove button. {name} becomes the file name.
    modelLabelstringModelAccessible name of the model picker.
    (send) / (stop)output-Angular only. Outputs for send and stop; the text supports [(value)] and the picker [(model)]. Svelte uses onSend, onStop, bind:value, and bind:model. Astro dispatches send and stop on markas-prompt-input and follows its loading attribute.

    Accessibility

    • The field is a native textarea named by inputLabel, with a native maxlength. The whole box shows the focus ring while the field has focus.
    • Enter sends and Shift+Enter inserts a new line. Enter is ignored while an IME is composing.
    • The send button is disabled until there is text. While loading it stays enabled and is named by stopLabel.
    • The file input is hidden and opened by the attach button. Each chip has a remove button named with the file name, and removing one moves focus back to the field.

    Related components

    More markasui components with the same classes in every framework.