Prompt suggestions
Up to four suggested prompts as a list of buttons.
Example
<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>import { useEffect, useRef } from 'react';import '@focsd-dev/ai';
export function Example() { const ref = useRef(null); return <focsd-prompt-suggestions ref={ref} label="Try asking"></focsd-prompt-suggestions>;}<script setup>import '@focsd-dev/ai';</script>
<template> <focsd-prompt-suggestions label="Try asking"></focsd-prompt-suggestions></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/ai';
// template<focsd-prompt-suggestions label="Try asking"></focsd-prompt-suggestions><script> import '@focsd-dev/ai';</script>
<focsd-prompt-suggestions label="Try asking"></focsd-prompt-suggestions>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
label | label | string | — |
CSS parts
Style the inside of the component with ::part(), for example focsd-prompt-suggestions::part(list).
| Part | Description |
|---|---|
list | The list of suggestions. |
suggestion | Each 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-selectwithdetail.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
| Key | Action |
|---|---|
| Tab | Move between suggestions |
| Enter / Space | Choose the suggestion |
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.