Back to Copilotkit

Input

showcase/shell-docs/src/content/reference/channels/components/Input.mdx

1.65.01.5 KB
Original Source

Input describes a single- or multiline text field.

tsx
import { Button, Input, Message } from "@copilotkit/channels/ui";

<Message>
  <Input
    name="reason"
    placeholder="Why should this be approved?"
    multiline
    onSubmit={async (ctx) => {
      await ctx.thread.post(`Recorded: ${String(ctx.action.value)}`);
    }}
  />
  <Button
    value="approve"
    onClick={async (ctx) => {
      const reason = ctx.values?.reason;
      if (reason !== undefined) {
        await ctx.thread.post(`Recorded: ${String(reason)}`);
      }
    }}
  >
    Approve
  </Button>
</Message>;

Props

PropTypeDescription
namestringLogical field name.
placeholderstringNative placeholder or label text.
multilinebooleanRequests a multiline native input.
onSubmitClickHandler<string>Text submission callback where the provider dispatches it.

Managed Slack renders a dispatching plain-text input block. Managed Teams renders Input.Text. Give the field a name and place it with a submitting Button; Teams sends the text to the Button callback in ctx.values[name], while Slack invokes Input.onSubmit as soon as the input is dispatched. Teams does not dispatch Input.onSubmit independently.