Skip to content
Focsd homeFocsd homeFocsd
Forms

Prompt suggestions

Up to four suggested prompts as a list of buttons.

  • Tag: focsd-prompt-suggestions
  • Pattern: List of buttons
  • Category: AI

Example

HTML
<focsd-prompt-suggestions id="suggest-demo" label="Try asking"></focsd-prompt-suggestions>
<script type="module">
const suggestions = document.getElementById('suggest-demo');
suggestions.suggestions = ['Explain streaming markdown', 'Show a tool call', 'Write a long answer'];
suggestions.addEventListener('focsd-suggestion-select', (event) => console.log(event.detail.text));
</script>

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-prompt-suggestions label="Try asking"></focsd-prompt-suggestions>

API

Attributes

AttributePropertyTypeDefault
labellabelstring—

CSS parts

Style the inside of the component with ::part(), for example focsd-prompt-suggestions::part(list).

PartDescription
listThe list of suggestions.
suggestionEach suggestion button.

Accessibility

  • A list named by label (default "Suggestions") of real buttons. Each button is its own tab stop; arrow keys are not used.
  • Choosing one fires focsd-suggestion-select with detail.text; sending it is up to your app (chat.send(text)).
  • At most four are shown, and the list wraps on narrow screens. An empty list renders nothing.

Keyboard

KeyAction
TabMove between suggestions
Enter / SpaceChoose the suggestion