Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

Choosing a score

Use the scale for a question with a numbered answer, and let each end carry a short word.

Nothing chosen yet
The words are not values. "Not likely" and "Very likely" sit under the ends of the scale; they are labels, not choices, and the value posted is the number.
How likely are you to recommend us?
Not likelyVery likely
Choose a number from 0 to 10.
Show code
<app-score-scale label="How likely are you to recommend us?" name="nps" low-label="Not likely" high-label="Very likely" helper-text="Choose a number from 0 to 10."></app-score-scale>

A chosen value

A chosen score stays visible, so a person can see what they picked before they move on.

A chosen value
How likely are you to recommend us?
Not likelyVery likely
Show code
<app-score-scale label="How likely are you to recommend us?" name="nps" value="7" low-label="Not likely" high-label="Very likely"></app-score-scale>

Disabled and errors

Lock the scale once the score is fixed, and show an error beneath it when the answer is missing.

Disabled
How likely are you to recommend us?
Not likelyVery likely
Show code
<app-score-scale label="How likely are you to recommend us?" value="7" disabled="true" low-label="Not likely" high-label="Very likely"></app-score-scale>
With an error
How likely are you to recommend us?
Not likelyVery likely
Choose a score.
Show code
<app-score-scale label="How likely are you to recommend us?" name="nps" error="Choose a score." low-label="Not likely" high-label="Very likely"></app-score-scale>

Every option

Every value of every prop, one cell each.

value: no choice, or the chosen number

value omitted (default)
value="7"

min: the lowest value

min="0" (default)
min="5"

max: the highest value

max="10" (default)
max="5"

label: the visible group label

label omitted (default)
label="How likely are you to recommend us?"
How likely are you to recommend us?

lowLabel: the text under the lowest value

low-label omitted (default)
low-label="Not likely"
Not likely

highLabel: the text under the highest value

high-label omitted (default)
high-label="Very likely"
Very likely

name: the form field name

name omitted (default)
name="nps"
name="nps-model" (React: name and value)

disabled: lock every radio

disabled="false" (default)
disabled="true"

error: a message under the scale

error omitted (default)
error="Choose a score."
Choose a score.

helperText: text under the scale

helper-text omitted (default)
helper-text="Choose a number from 0 to 10."
Choose a number from 0 to 10.

id: the radiogroup id

id="every-score" (React only): Razor generates the radiogroup id

className: a class on the radio group

input-class="every-score-class" (React className): a class on the radio group, no visible change

fieldClassName: a class on the field wrapper

class="every-score-field" (React fieldClassName): a class on the field wrapper, no visible change

scoreLabel: the name when there is no label

score-label="Rating": the screen reader name when there is no label

onChange: the chosen number

onChange (React only): Razor posts the value through name

Guidance

What to do, and what to avoid.

Use it when

  • Likelihood to recommend, satisfaction or effort on a numbered scale.
  • A single answer from a short, ordered run of numbers.

Reach for something else when

  • A rating of a product or review as stars. → AppRating
  • A choice between named options. → AppRadioGroup
  • A numeric amount along a range. → AppSlider

Reference

Try every prop, read the full list, and check keyboard and screen reader behaviour.

How likely are you to recommend us?
Not likelyVery likely
React, generated from the controls
<AppScoreScale value={7} label="How likely are you to recommend us?" lowLabel="Not likely" highLabel="Very likely" name="pg-score" onChange={setValue} />
Razor, the same props
<app-score-scale label="How likely are you to recommend us?" name="pg-score" value="7" low-label="Not likely" high-label="Very likely"></app-score-scale>

13 props. The 5 most used come first.

Used on most screens 5 props

PropTypeDefaultDescription
valuedefault - string - The chosen value, or null for no choice yet. The parent holds it (controlled).
mindefault 0 int 0 The lowest value on the scale.
maxdefault 10 int 10 The highest value on the scale.
labeldefault - string - The visible group label; names the group.
low-labeldefault - string - Text under the lowest value, such as "Not likely".

Less common 8 props

PropTypeDefaultDescription
asp-fordefault - model property - Supplies the name, the chosen value and the validation message when no explicit one is given.
score-labeldefault Score string Score Replaces the built-in English text, for other languages.
high-labeldefault - string - Text under the highest value, such as "Very likely".
namedefault from asp-for string from asp-for The form field name carried by every radio. Defaults to a generated one.
disableddefault false bool false Locks every radio so the score cannot be changed.
errordefault - string - Message below the scale. Replaces the helper text.
helper-textdefault - string - Helper text below the scale.
input-classdefault - string - Extra classes on the radio group itself (the control), the React className counterpart. The plain class attribute merges onto the .field wrapper instead.

Screen reader

3 notes
  • The scale is a radio group named by its label, or named Score when there is no label.
  • Each value is a native radio sharing one name, so the arrow keys move and choose and the group posts with its form.
  • Helper text or an error is linked through aria-describedby, and an error also sets aria-invalid.