Message actions
A toolbar for one reply: copy, retry and good or bad response.
Example
<focsd-message-actions for="demo" text="A feed announces one reply at a time."></focsd-message-actions>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/ai';</script>
<focsd-message-actions for="demo" text="A feed announces one reply at a time."></focsd-message-actions>import { useEffect, useRef } from 'react';import '@focsd-dev/ai';
export function Example() { const ref = useRef(null); return <focsd-message-actions ref={ref} for="demo" text="A feed announces one reply at a time."></focsd-message-actions>;}<script setup>import '@focsd-dev/ai';</script>
<template> <focsd-message-actions for="demo" text="A feed announces one reply at a time."></focsd-message-actions></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/ai';
// template<focsd-message-actions for="demo" text="A feed announces one reply at a time."></focsd-message-actions><script> import '@focsd-dev/ai';</script>
<focsd-message-actions for="demo" text="A feed announces one reply at a time."></focsd-message-actions>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
for | for | string | — |
text | text | string | — |
actions | actions | string | string[] | copy,retry,feedback |
feedback | feedback | FeedbackValue | null |
CSS parts
Style the inside of the component with ::part(), for example focsd-message-actions::part(toolbar).
| Part | Description |
|---|---|
toolbar | The toolbar. |
action | Each action (the copy button element and the native buttons). |
Accessibility
- A
role="toolbar"named "Message actions" with one tab stop; the arrow keys, Home and End move between the actions (mirrored in right-to-left text). - Copy is
focsd-copy-buttonand says "Copied". Retry firesfocsd-retrywith the message id. - The thumbs are toggle buttons with
aria-pressed; choosing one announces "Marked as a good response" or "Marked as a bad response", and taking it back announces "Feedback removed". It firesfocsd-feedbackwithvalueofup,downor null.
Keyboard
| Key | Action |
|---|---|
| Arrow Left / Right | Move between the actions |
| Home / End | First / last action |
| Enter / Space | Use the action |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.