Back to Copilotkit

Button

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

1.64.21.2 KB
Original Source

Button creates the most portable managed interaction control.

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

<Actions>
  <Button
    value={{ approved: true }}
    style="primary"
    onClick={async ({ action, thread }) => {
      if (action.value) await thread.resume(action.value);
    }}
  >
    Approve
  </Button>
</Actions>;

Props

PropTypeDescription
valueTValueJSON-serializable value returned as ctx.action.value. It also infers the callback value type.
onClickClickHandler<TValue>Callback for a native button submission.
urlstringCreates a native link button. When set, onClick and value are ignored.
style"primary" | "danger"Maps to the closest provider emphasis.
childrenBotChildrenButton label.

Managed Slack renders a Block Kit button. Managed Teams renders Action.Submit, or Action.OpenUrl when url is set. A Teams submission can arrive without a source message reference, so only call thread.update() when ctx.message.ref.id is non-empty.

Register the named component that owns onClick. Add a durable StateStore when buttons must remain usable across a runner restart.