Cancellation Reason Survey
ProOne optional question in a cancel flow: reasons as radio rows, a note field that opens under the reasons that need detail, and skip and send actions of equal weight. Use it before the final confirmation.
How it differs. A hairline list of radio rows where a follow-up field opens inside the chosen row, above a footer that restates the answer and offers skip and send as two equal outline buttons.
Install
pnpm dlx shadcn@latest add @hazine/cancellation-reason-surveyAdds 1 file, 3 shadcn primitives (button, label, textarea), 2 Hazine items (@hazine/heading, @hazine/use-controllable-state), and 1 package (lucide-react).
First time? Add the registry to components.json
{
"registries": {
"@hazine": {
"url": "https://api.hazine.dev/r/{name}.json",
"headers": { "Authorization": "Bearer ${HAZINE_TOKEN}" }
}
}
}Set HAZINE_TOKEN in your environment. The token comes with a Pro licence.
The source of a Pro item is not published on this site. It installs into your codebase with the same command once your registry entry carries a Pro token.
- components/blocks/cancellation-reason-survey.tsx
- 432 lines
- 1 file
- 432 lines
pnpm dlx shadcn@latest add @hazine/cancellation-reason-surveyAdds 1 file, 3 shadcn primitives (button, label, textarea), 2 Hazine items (@hazine/heading, @hazine/use-controllable-state), and 1 package (lucide-react).
Props14
- title
- string = "What is the main reason you are cancelling?"
- reasons
- CancellationReason[] = DEFAULT_REASONS
- value
- CancellationAnswer
- defaultValue
- CancellationAnswer = NO_ANSWER
- onValueChange
- (answer: CancellationAnswer) => void
- onAnswerSubmit
- (reason: CancellationReason, detail: string) => void
- Called by "Send and continue" with the chosen reason and the trimmed note, empty when none.
- onSurveySkip
- () => void
- Called by the skip action. Nothing typed or chosen is passed on.
- loading
- boolean = false
- The answer is being sent. Controls lock and the submit label becomes "Sending".
- error
- string
- Why the answer could not be sent. The skip action stays available.
- planName
- string = "Team"
- accessEndsOn
- string = "2026-12-14"
- ISO date the plan stays active until, whatever happens on this step.
- keepPlanHref
- string = "#plan"
- locale
- string = "en-US"
- headingLevel
- HeadingLevel = 2
Also accepts every prop of Omit<React.ComponentProps<"section">, "title" | "defaultValue">.
Accessibility
- Pattern
- Radio Group (APG, opens in a new tab), Form with labelled fields, Landmarks and headings
- Keyboard
Keyboard support for Cancellation Reason Survey Key Effect Tab Moves to the reason group, the open follow-up field, Clear answer, Skip this question, Send and continue, then the keep plan link Arrow keys Move between reasons and select the focused one. Focus stays on the radio when a follow-up field opens under it Space Selects the focused reason Enter on a reason Sends the answer when a reason is selected. Does nothing while none is Enter or Space on Clear answer Deselects the reason, keeps the typed note for later and moves focus to the first reason Enter or Space on Skip this question Leaves the step without sending anything Enter or Space on Send and continue Sends the selected reason and its note. Disabled until a reason is selected - Screen reader
A section labelled by its heading. The reasons are native radios in a fieldset whose legend holds the heading. Each radio is named by its label alone and described by its follow-up hint and description. A follow-up textarea sits directly after its radio in DOM order with its own label, hint and character count, and is never required. The current answer, the sending state and a note that reaches the character limit are restated in a status region, and a failed send is reported through an alert.
- Announces: No answer selected. Choose a reason to send one, or skip.
- Announces: Your answer: {reason}. You can add a note under it, or leave it blank.
- Announces: Your answer: {reason}. Your note is sent with it.
- Announces: Your answer: {reason}. Your note is sent with it. It has reached the limit of 500 characters.
- Announces: Sending your answer: {reason}.
- Announces: {error} Try again, or continue without sending.
- Reduced motion
- The spinner in the sending state does not rotate. Everything else is colour transitions only.
- Checked
- Not checked yet. Automated results appear here once CI has run.
Dependencies6
- button
- label
- textarea
- @hazine/heading
- @hazine/use-controllable-state
- lucide-react
Filled chips are registry items the CLI adds for you. Outlined chips are npm packages.
Tokens shipped0
None. The item is styled by the tokens your theme already has.