A dark feedback form built with Bootstrap 6, for post-purchase surveys, support tickets or in-app "rate your experience" prompts. It has a five-star rating, quick tag chips, a comment box with a live character counter, an optional "contact me" switch, and a thank-you state after sending.
How it works
The root .fbr-root is pinned to data-bs-theme="dark", so Bootstrap's form controls use their dark tokens in every OS mode. The form uses data-bs-validate and novalidate, so Bootstrap shows .invalid-feedback through :user-invalid without extra CSS.
The rating is a <fieldset class="fbr-rating"> with five real radio inputs (.fbr-star-input), each followed by a <label class="fbr-star"> that draws an inline SVG star. CSS alone fills the stars up to the checked one (.fbr-star-input:checked + .fbr-star ~ .fbr-star) and previews the hovered star with :has(.fbr-star:hover). The script only updates the .fbr-word text ("Good", "Excellent") from the WORDS array.
A rating of LOW_RATING (2) or lower makes the comment required. The script sets setCustomValidity() on .fbr-comment until it has 10 characters and changes the placeholder to ask what went wrong. The counter .fbr-count follows maxlength and turns amber after 90 percent.
The "What stood out?" tags are Bootstrap 6 .chip buttons. A click toggles .active and aria-pressed. The .switch reveals .fbr-email, makes the email required and focuses it.
On submit the script calls preventDefault(), checks the rating and the form, then simulates sending with a spinner. It hides the form and shows .fbr-thanks with a summary. "Edit my answer" brings the form back with the answers still in place. "Not now" shows a short message instead.
Customization
--fbr-violetand the--bs-primary-*overrides on.fbr-root: change the button, switch, chip and focus color.--fbr-starand--fbr-star-off: color the filled and empty stars.--fbr-bg,--fbr-cardand--fbr-line: adjust the page, card and border colors.- The
WORDSarray inscript.js: rename the rating labels or translate them. LOW_RATINGinscript.js: set the rating at or below which a comment becomes required.data-fbr-tagon each.chip: sets the tag value sent with the form. Add or remove chips freely.- Replace the
setTimeoutin the submit handler with afetch('/api/feedback', ...)call that postspayload.
Use cases
- Product and app feedback: an accessible 5-star rating gathers a quick score
- Customer support follow-ups: tag chips let users label what the feedback is about
- Post-purchase surveys: a comment box with a character counter collects details
- Privacy-friendly forms: an optional contact switch asks permission before a reply, then a thank-you state shows
Accessibility
The stars are native radios in a <fieldset> with a <legend>, so arrow keys change the rating and screen readers announce "4 stars, good" from the visually hidden label text. The focused star shows an outline. .fbr-word is a polite live region. Chips use aria-pressed, the switch uses role="switch" with aria-expanded, and errors are linked with aria-describedby. The thank-you panel receives focus. Star animations are turned off under prefers-reduced-motion.
Bootstrap 6 notes
form-check and form-switch are replaced by <div class="switch"> with an <input switch> inside a .form-field. Tags use the new .chip component, buttons use btn-solid theme-primary and btn-text theme-secondary, and data-bs-validate replaces needs-validation. Built on Bootstrap 6.0.0-alpha.1, so APIs can still change. Icons come from Bootstrap Icons.