Suggestion
Prompt chips that fill the input when you click one.
Installation
pnpm add @heyramzi/uiUsage
import { Suggestions, Suggestion } from "@heyramzi/ui/ai/suggestion";<Suggestions>
{#each ideas as idea (idea)}
<Suggestion suggestion={idea} onclick={(text) => (value = text)} />
{/each}
</Suggestions>Keyboard and accessibility
| Key | Does |
|---|---|
| Tab | Moves focus to the next suggestion. |
| Space Enter | Picks the focused suggestion. |
- The row is a group named "Suggestions". Pass label to say more, like "Suggested prompts".
API reference
Suggestions.Suggestion
suggestionrequiredstringonclick(suggestion: string) => voidclassstringchildrenimport("svelte").Snippetvariant"default" | "outline" | "ghost" | "destructive" | "text" | "dashed"- Default
"outline" size"sm" | "default" | "lg"- Default
"sm" iconbooleanrefHTMLButtonElement | HTMLAnchorElement | null...rest- Every prop of
HTMLButtonAttributesfromsvelte/elementsexceptchildren, onclick ...rest- Every prop of
HTMLAnchorAttributesfromsvelte/elementsexceptchildren, onclick
| Prop | Type | Default |
|---|---|---|
suggestion required | string | |
onclick | (suggestion: string) => void | |
class | string | |
children | import("svelte").Snippet | |
variant | "default" | "outline" | "ghost" | "destructive" | "text" | "dashed" | "outline" |
size | "sm" | "default" | "lg" | "sm" |
icon | boolean | |
ref | HTMLButtonElement | HTMLAnchorElement | null | |
...rest | Every prop of HTMLButtonAttributes from svelte/elements except children, onclick | |
...rest | Every prop of HTMLAnchorAttributes from svelte/elements except children, onclick | |
Suggestions.Suggestions
childrenSnippetlabelstring- Default
"Suggestions" - The group's name for a screen reader.
classstring...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
children | Snippet | |
label The group's name for a screen reader. | string | "Suggestions" |
class | string | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |