Suggestions
FreeStarter prompts for an empty conversation, or follow-ups under an answer — as a list, a two-column grid or wrapping chips.
import { SvSuggestionsComponent } from '@styloviz/ai/suggestions';Demo & usage
Basic usage
Usage example — open the gallery for the full interactive demo.
An interactive demo for this component lives in the gallery.
Open live demoMore examples
Chips, capped at three
<sv-suggestions layout="chips" [max]="3" [suggestions]="followUps()" (selected)="send($event.prompt ?? $event.label)" />
Fetched from your API
<sv-suggestions [suggestions]="prompts()" [loading]="loading()" [error]="error()" (retry)="reload()" (selected)="send($event.prompt ?? $event.label)" />
When to use
The empty state of a chat, where a blank box gives the user nothing to start from. Follow-up questions under an answer, generated by the model or picked by you. For a searchable library of saved prompts, use the Prompt Template Library instead.
Async states
- loading
- error
- retry
Item identity & owned state
- Item key
itemKey— set this when your rows have noid, so selection survives a reorder.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| suggestions | readonly SvSuggestion[] | [] | The prompts to offer. |
| layout | SvSuggestionsLayout | 'list' | `list` (stacked rows), `grid` (two columns from `sm`) or `chips` (wrapping pills). |
| max | number | 0 | Show at most this many; `0` shows them all. Negative or non-finite values count as `0`. |
| disabled | boolean | false | Disable every suggestion — while a reply is in flight, for instance. |
| loading | boolean | false | True while the host is fetching suggestions. |
| error | SvDataError | string | null | null | The last failure fetching suggestions, or null. |
| itemKey | SvItemKey<SvSuggestion> | 'id' | Stable identity for each suggestion. |
| ariaLabel | string | null | null | The list's accessible name; `null` uses the `suggestions` label. |
| labels | Partial<SvAiLabels> | {} | Per-instance text, merged over the registry's `ai` labels. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| selected | SvSuggestion | The user picked a suggestion. |
| retry | void | The host should re-run the failed fetch. |
Wire it to your API
This component is headless about transport: it renders what you give it and reports what the user asks for. Nothing below requires @styloviz/data — drive it from whatever you already use.
Template
Bound to the names this component actually exposes.
<sv-suggestions [suggestions]="suggestions()" [loading]="loading()" [error]="error()" (retry)="load()" />
Host class
Drive the three async inputs from your own fetch.
import { signal } from '@angular/core'; import { toSvDataError, type SvDataError } from '@styloviz/core'; import type { SvSuggestion } from '@styloviz/ai/suggestions'; readonly suggestions = signal<SvSuggestion[]>([]); readonly loading = signal(false); readonly error = signal<SvDataError | null>(null); async load(): Promise<void> { this.loading.set(true); this.error.set(null); try { const res = await fetch('/api/suggestions'); if (!res.ok) throw res; this.suggestions.set(await res.json()); } catch (e) { this.error.set(toSvDataError(e)); } finally { this.loading.set(false); } }
This component does not emit a query, so it renders what you give it. Call `load()` on your own trigger and bind `suggestions`, `loading` and `error`. Normalize failures with `toSvDataError()` from `@styloviz/core`. It derives `retryable` from the status, so a 404 does not get a "Try again" button that can only fail again.
Full walkthrough: Connecting to a backend.
Customization & theming
Three layouts via `layout`: `list` (stacked rows with a description line), `grid` (two columns from `sm`) and `chips` (wrapping pills, label only). `[max]` shows the first N; `0` — the default — shows them all. Wire it to a backend with `loading`, `error`, `retry` and `itemKey`: a skeleton while loading, an error with a working retry, and an empty state that says there is nothing to suggest. Text comes from the `ai` labels (`provideSvLabels({ ai: { … } })`), or per instance through `[labels]`. Free tier: uses only free icons, and composes into `sv-ai-chat`.
Best practices
Do: Give each suggestion a `prompt` when the full text is longer than the label — the button stays short and the message stays complete. Do: Set `[disabled]` while a reply is streaming, so a second prompt cannot start over the first. Don't: Do not offer more than a handful. `[max]` caps the list; past four or five, a suggestion list is a menu nobody reads. Tip: An icon name in your data is yours to register with `provideSvIcons`, like any data-driven glyph.
Accessibility
A named list of real buttons — every suggestion is one Tab stop and fires on Enter or Space. A disabled list disables every button, so it is skipped rather than pressed silently. The icon tile is decorative and hidden from assistive technology; the label carries the meaning.
Feedback on Suggestions
Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.