Props
| Name | Type | Default | Description |
|---|---|---|---|
autofocus | Booleanish | undefined | - | Sets autofocus on page load. |
clearable | boolean | undefined | false | Allows clearing the selected rating by clicking the current value. Adds the only way back to unrated, since a radio group cannot be un-picked: click the selected star again, or press Delete or Backspace on it. Neither gesture is discoverable, so pair it with a hint — and expect |
compact | boolean | undefined | false | Sets the component in a compact state. |
description | string | undefined | - | Descriptive text displayed below the label and above the input. Unlike the hint it is always
visible, and it is linked to the input via Always visible, above the stars. The place for what the scale means before anyone picks a point on it. See example |
direction | InputDirection | undefined | - | Direction of the layout of the component. Can either be a predefined value or a pattern separated by a space like |
disabled | boolean | undefined | false | Disables the component. Takes the group out of the tab order, so the score is missing entirely for someone navigating by keyboard. Prefer |
errors | string | string[] | undefined | - | Can be a string or an array of string containing the messages to display.
They render in an Applies to the whole fieldset rather than to one star. Clear it as soon as a value is picked — a form that keeps shouting after the user complied is a form people stop reading. See example |
hasErrors | boolean | undefined | false | Define if the component should be in an error state. It usually attaches a CSS class for styling purposes. |
hasWarnings | boolean | undefined | false | Define if the component should be in a warning state.
Same chrome as errors with |
hideLegend | boolean | undefined | false | Visually hides the legend of the fieldset while maintaining accessibility. Keeps the accessible name and removes only the visible text, which is what a score under a product title wants. |
hint | string | undefined | - | Text box to be displayed near the input, usually to indicate instructions. |
id | string | undefined | - | The identifier of the component. |
inputPosition | "left" | "center" | "right" | undefined | "left" | Sets the alignment of the input. Since inputs are inline block they can be aligned just as text can. Aligns the row of stars within its column. It was accepted, typed and documented in v2 and did nothing — the rules targeted a class this component never rendered. v3 repoints them, so a hand-rolled alignment workaround now fights the library and should be deleted. See example |
legendrequired | string | - | Text content of the legend. The family says |
legendMode | "outside" | "inside" | undefined | - | Legend rendering mode. Places the legend the way |
legendPosition | "left" | "center" | "right" | undefined | - | Sets the text alignment of the legend. |
modelValuerequired | number | null | - | Used by v-model. |
name | string | undefined | - | Defines the name of the star radio inputs. Optional: the stars live inside a single component instance, so an omitted name falls back to a generated one that groups them correctly on its own. Pass a name only when the value has to be submitted under a known key by a native (non-JS) form post. Optional in v3, required in v2. Omitted, the component generates a group name that is unique and stable for the instance, so two ratings on one page cannot bleed into each other. Pass it when a native form post needs the value under a key you chose. See example |
persistentHint | boolean | undefined | false | Keeps the hint displayed. |
pt | PtMap<BbRatingPtPart, BbRatingPtState> | undefined | - | Passthrough, object form: the same keys as the |
pt:description | PtValue | undefined | - | |
pt:description:disabled | PtValue | undefined | - | |
pt:description:errors | PtValue | undefined | - | |
pt:description:has-value | PtValue | undefined | - | |
pt:description:readonly | PtValue | undefined | - | |
pt:description:selected | PtValue | undefined | - | |
pt:description:warnings | PtValue | undefined | - | |
pt:hint | PtValue | undefined | - | |
pt:hint:disabled | PtValue | undefined | - | |
pt:hint:errors | PtValue | undefined | - | |
pt:hint:has-value | PtValue | undefined | - | |
pt:hint:readonly | PtValue | undefined | - | |
pt:hint:selected | PtValue | undefined | - | |
pt:hint:warnings | PtValue | undefined | - | |
pt:item | PtValue | undefined | - | |
pt:item:disabled | PtValue | undefined | - | |
pt:item:errors | PtValue | undefined | - | |
pt:item:has-value | PtValue | undefined | - | |
pt:item:readonly | PtValue | undefined | - | |
pt:item:selected | PtValue | undefined | - | |
pt:item:warnings | PtValue | undefined | - | |
pt:label | PtValue | undefined | - | |
pt:label:disabled | PtValue | undefined | - | |
pt:label:errors | PtValue | undefined | - | |
pt:label:has-value | PtValue | undefined | - | |
pt:label:readonly | PtValue | undefined | - | |
pt:label:selected | PtValue | undefined | - | |
pt:label:warnings | PtValue | undefined | - | |
pt:message | PtValue | undefined | - | |
pt:message:disabled | PtValue | undefined | - | |
pt:message:errors | PtValue | undefined | - | |
pt:message:has-value | PtValue | undefined | - | |
pt:message:readonly | PtValue | undefined | - | |
pt:message:selected | PtValue | undefined | - | |
pt:message:warnings | PtValue | undefined | - | |
pt:root | PtValue | undefined | - | |
pt:root:disabled | PtValue | undefined | - | |
pt:root:errors | PtValue | undefined | - | |
pt:root:has-value | PtValue | undefined | - | |
pt:root:readonly | PtValue | undefined | - | |
pt:root:selected | PtValue | undefined | - | |
pt:root:warnings | PtValue | undefined | - | |
readonly | boolean | undefined | false | Sets the input in a readonly state. Keeps the group focusable and exposes |
required | boolean | undefined | false | Sets the input as required. Applies to the fieldset, so it is satisfied by any star. Combine with |
reverse | boolean | undefined | false | Reverses the layout. Applicable in every direction the order of the label and the input is swapped. |
size | number | ({ size?: any; } & string) | keyof Sizes | undefined | 'md' | Defines the component size.
Accepted values:
- A key from the provided size map ( The glyph size only — never the number of stars and never the value, both of which are |
stars | number | undefined | 5 | Maximum number of stars to render and maximum value of the component. Sets the number of glyphs and the maximum value at once. Past ten or so a row of identical glyphs stops being countable at a glance; a |
warnings | string | string[] | undefined | - | Warning messages to display beneath the field, in their own The amber counterpart of |
v-model
Values kept in sync through v-model.
| Name | Type | Description |
|---|---|---|
modelValue | number | null |
|
Events
| Name | Type | Description |
|---|---|---|
active | (event: "active"): void | |
blur | (event: "blur", event: FocusEvent): void | |
change | (event: "change", event: Event): void | |
click | (event: "click", event: MouseEvent): void | |
focus | (event: "focus", event: FocusEvent): void | |
inactive | (event: "inactive"): void | |
input | (event: "input", event: Event): void | |
keydown | (event: "keydown", event: KeyboardEvent): void | |
mousedown | (event: "mousedown", event: MouseEvent): void | |
mouseup | (event: "mouseup", event: MouseEvent): void | |
update:modelValue | (event: "update:modelValue", value: number | null): void |
Slots
The listed properties are the ones exposed to the slot scope.
| Name | Type | Description |
|---|---|---|
append | object | Content rendered after the row of rating stars. Where the precise figure and the sample size go, because there are no half stars: a 4.6 average fills four, so round for the glyphs and print the decimal as text. See example |
description | BbRatingDescriptionSlotProps | Replaces the description text. Provided alone (no |
icon | BbRatingIconSlotProps | Replaces the default star SVG for each rating option. Replaces the star glyph and nothing else. |
legend | BbRatingLegendSlotProps | Replaces the default fieldset legend text rendered above the rating stars. |
prepend | object | Content rendered before the row of rating stars. |
Changes from v2
Props removed or renamed in 3.0. If you are coming from v2, the answer is here.
colorremovedfails silentlyhasWarninghasWarningsfails silently