# Net Promoter Score View

A Net Promoter Score (NPS) view is a display component that presents an NPS score value as read-only text. It is used to show previously captured NPS data in dashboards, reports, or detail views. NPS scores range from 0 to 10, with respondents classified as Detractors (0-6), Passives (7-8), or Promoters (9-10).

**Status:** stable — exercised in composed page flows under e2e and axe, beyond the per-component checks.

This headless component renders as a `<span>` element with an accessible label, providing the semantic structure and accessibility features while allowing consumers to apply their own visual styling, such as color-coding by score range.

## Implementation Notes

- No ARIA on the root: a plain `<span>` cannot be named. A visible caption names the value, or `label` renders as hidden text in a `.screen-reader-span`
- Displays the NPS score value as inline text content
- Read-only display component, not interactive
- Uses props for prop destructuring with rest props spread
- Value defaults to empty string when not provided
- No score validation or classification logic; consumers handle categorization and styling
- No hardcoded strings; all text comes through props for internationalization

## Props

- `label`: string (optional) — hidden text naming the value, in a `.screen-reader-span`. Leave it out when a visible caption names the value
- `value`: string (default: `""`) -- the NPS score to display
- `...restProps`: any -- additional HTML attributes spread onto the `<span>` element

## Usage

```html
<NetPromoterScoreView
  label="NPS Score"
  value="8"
/>
```

In an analytics dashboard:

```html
<Card>
  <h3>Customer Loyalty</h3>
  <NetPromoterScoreView
    label="Latest NPS score"
    value="9"
  />
  <Badge>Promoter</Badge>
</Card>
```

## Keyboard Interactions

- None -- this is a passive informational display, not interactive

## ARIA

## When to Use

- Use to display a previously captured NPS score in dashboards, reports, or detail views.
- Use when the score should be visible but not editable by the user.
- Use in analytics dashboards to show individual respondent scores with color-coded Detractor/Passive/Promoter styling.

## When Not to Use

- Do not use when the user needs to select or change the score -- use NetPromoterScoreRadioGroup instead.
- Do not use for star-based display -- use FiveStarRatingView instead.

## Headless

This headless component renders a `<span>` with the NPS score as text content and `aria-label` for accessible context. The consumer provides all visual styling, including typography, color coding by score range (Detractor, Passive, Promoter), and layout.

## Styles

The consumer provides all CSS styling. The component renders with a `.net-promoter-score-view` class for targeting. No default styles are included — this is a fully headless component.

## Testing

- Verify the component renders a `<div>` element with class `net-promoter-score-view`
- Verify `label` renders as hidden text, and that the root has no `aria-label`
- Verify keyboard interactions work correctly
- Verify pass-through attributes are applied

## Advice

- **Designers**: Color-code displayed scores by range (e.g., red for Detractors 0-6, yellow for Passives 7-8, green for Promoters 9-10) and display the category label alongside the number.
- **Developers**: Provide a descriptive `label` prop (e.g., "Customer NPS score") so screen reader users understand the context of the displayed number.

## Related components

- `net-promoter-score-radio-group` — a picker for selecting a 0-10 Net Promoter Score

## Known limitations

None known.

## References

- Net Promoter Score: https://en.wikipedia.org/wiki/Net_promoter_score

---

Lily™ and Lily Design System™ are trademarks.
