Survey (NPS / CSAT)
FreeAn in-app survey: Net Promoter Score (0–10), CSAT (1–5 stars) or one question of your own, as a native radio group with an optional follow-up comment whose prompt follows the NPS band, then a thank-you with an optional follow-up action. As a card, inline, or a floating corner panel. It emits a typed response; saving it is yours.
import { SvSurveyComponent } from '@styloviz/forms/survey';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
NPS with a prompt per band
<sv-survey kind="nps" question="How likely are you to recommend Acme to a friend or colleague?" [followUpPrompts]="{ detractor: 'What disappointed you most?', promoter: 'What do you like most?' }" (submitted)="save($event)" /> save(response: SvSurveyResponse): void { // { kind: 'nps', score: 9, band: 'promoter', comment: 'Fast support' } this.api.post('/feedback', response).subscribe(); }
CSAT after a support ticket
<sv-survey kind="csat" layout="inline" question="How satisfied are you with the help you got?" (submitted)="save($event)" />
One question — options or free text
<sv-survey kind="question" question="What brought you here today?" [options]="reasons" (submitted)="save($event)" /> <!-- No options: a free-text answer --> <sv-survey kind="question" question="What should we build next?" (submitted)="save($event)" />
Floating, dismissible, with a follow-up action
@if (showSurvey()) { <sv-survey kind="nps" layout="floating" [dismissible]="true" thanksActionLabel="Book a call" thanksActionHref="/research/book" [(open)]="showSurvey" (submitted)="save($event)" /> }
When to use
Measuring loyalty (NPS) or satisfaction (CSAT) inside your SaaS product, admin panel or helpdesk, at the moment the experience happened. Asking one quick question — "What brought you here?", "What should we build next?" — without sending the user to a separate survey tool. Use `sv-rating` instead when the score is one field among others in a form you already submit.
Compare with
- Rating — Rating is a form control for a score inside your own form, with half steps and hover preview. Survey is the whole in-app ask — question, scale, follow-up, submit and thank-you — for NPS, CSAT or one question.
Async states
None — this component has nothing to load, so it has no loading, empty or error state to drive.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| kind | SvSurveyKind | 'nps' | `nps` (0–10), `csat` (1–5 stars) or `question` (one custom question). |
| question | string | null | null | The question. Null uses the kind's label ("How likely are you to recommend us…"). |
| description | string | null | null | A line under the question. |
| options | readonly SvSurveyOption[] | [] | The answers to a `question` survey, shown as radio pills. Empty asks for a free-text answer instead. Rows with an empty or duplicate `value` are skipped. |
| followUp | boolean | true | Ask an optional follow-up comment once a score or option is chosen. |
| followUpPrompt | string | null | null | The follow-up prompt. Null uses the `surveyFollowUp` label (or `surveyFollowUpChoice` for a question). |
| followUpPrompts | Partial<Record<SvNpsBand, string>> | {} | NPS only: a follow-up prompt per band, over `followUpPrompt` — e.g. ask a detractor "What disappointed you?" and a promoter "What do you like most?". |
| commentMaxLength | number | 1000 | Longest comment accepted, in characters. |
| thanksTitle | string | null | null | The thank-you heading. Null uses the `surveyThanksTitle` label. |
| thanksMessage | string | null | null | The thank-you message. Null uses the `surveyThanksMessage` label. |
| thanksActionLabel | string | null | null | Text of an optional follow-up action on the thank-you ("Book a call"). Null shows none. |
| thanksActionHref | string | null | null | Where the thank-you action goes. Relative paths, `http(s):` and `mailto:` are kept; anything else drops the link. With no `href` the action is a button that emits `thanksAction`. |
| layout | SvSurveyLayout | 'card' | `card`, `inline` or `floating` (fixed to a bottom corner, slides in). |
| corner | SvSurveyCorner | 'end' | Which bottom corner a `floating` survey sits in. |
| dismissible | boolean | false | Show a close button that hides the survey and emits `dismissed`. |
| labels | Partial<SvSurveyLabels> | {} | Per-instance text, merged over the registry's `forms` labels. |
| score | number | null (two-way) | null | The chosen score — NPS 0–10, CSAT 1–5. Two-way: `[(score)]`; picking one emits `scoreChange`. |
| choice | string | null (two-way) | null | The chosen option's `value` for a `question` survey. Two-way: `[(choice)]`. |
| comment | string (two-way) | '' | The follow-up comment, or the free-text answer. Two-way: `[(comment)]`. |
| state | SvSurveyState (two-way) | 'ask' | `ask` or `thanks`. Submitting sets `thanks`; set `ask` to ask again. Two-way: `[(state)]`. |
| open | boolean (two-way) | true | Whether the survey renders at all. Dismissing sets it `false`. Two-way: `[(open)]`. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| submitted | SvSurveyResponse | The user sent the survey: `{ kind, score?, band?, choice?, comment? }`. Save it; the survey shows its thank-you. |
| dismissed | void | The user closed the survey with its close button. |
| thanksAction | void | The user activated the thank-you action (its link, which also navigates, or its button). |
| scoreChange | number | null | Emits the new `score` whenever it changes — the output half of `[(score)]`. |
| choiceChange | string | null | Emits the new `choice` whenever it changes — the output half of `[(choice)]`. |
| commentChange | string | Emits the new `comment` whenever it changes — the output half of `[(comment)]`. |
| stateChange | SvSurveyState | Emits the new `state` whenever it changes — the output half of `[(state)]`. |
| openChange | boolean | Emits the new `open` whenever it changes — the output half of `[(open)]`. |
Customization & theming
Three kinds: `nps` (0–10 number pills, six to a row on a phone), `csat` (1–5 stars from the icon library) and `question` (your own options as pills, or free text when there are none). Three layouts: `card` (bordered panel), `inline` (no chrome) and `floating` (fixed to a bottom `corner`, slides in; the slide is skipped under reduced motion). Pills, the submit button and focus rings are painted from the `primary-*` tokens, so a template that remaps primary recolours the survey. `question`, `description`, `followUpPrompt`, `thanksTitle` and `thanksMessage` replace the default text; `commentMaxLength` caps the comment (1000 by default). Every string comes from the `forms` labels (`survey*` keys) — `provideSvLabels(SV_FORMS_LABELS_DE)` or the per-instance `labels` input. Host owns persistence: nothing is stored. `svNpsBand(score)` is exported for reporting on your side.
Forms integration
sv-survey— Output-driven, not a ControlValueAccessor. A whole ask with its own submit and thank-you, not a field in your form: listen to `(submitted)` for `{ kind, score?, band?, choice?, comment? }`. Bind `[(score)]`, `[(choice)]` and `[(comment)]` to pre-fill or restore an answer.
Best practices
Do: Ask at a natural pause — after a task completes or a ticket is resolved — and use `layout="floating"` so the page stays usable. Do: Make a floating survey `dismissible` and store `[(open)]`, so a user who closed it is not asked again on every visit. Do: Give each NPS band its own follow-up through `followUpPrompts` — a detractor and a promoter have different things to tell you. Don't: Don't pre-select a score. An answer the user never chose is not feedback. Tip: If saving fails, set `[(state)]` back to `ask` — the score and comment are still there, so nothing has to be typed again.
Accessibility
Every scale is native radio inputs in a `<fieldset>` whose `<legend>` is the question, so arrow keys move between answers, Space selects and the question is read on entry — no ARIA widget roles. NPS radios are named by their number; 0 and 10 are described by "Not likely" and "Very likely". Each CSAT star is named by its level ("Satisfied"), and the chosen level is written beside the stars, so colour never carries the answer alone. Answer targets are 40 px; every control has a visible focus ring. Submitting with nothing chosen says "Choose an answer first." in a polite live region, links it to the fieldset with `aria-describedby` and moves focus to the first answer. After submit, focus moves to the thank-you heading. The survey is a `<section>` named by its question (or the thank-you); `floating` is a region, not a dialog — no focus trap, no inert page.
Feedback on Survey (NPS / CSAT)
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.