rating Renderer
renderAs: 'rating' renders a numeric value as a row of filled and empty icons — stars by default. Use it for quality scores, satisfaction ratings, or any discrete 1-to-N metric.
Core Examples
Basic Rating
Five-star rating with filled amber stars and grey empty stars.
{
key: 'stars',
renderAs: 'rating',
renderAsOptions: { max: 5, size: 16, color: '#f59e0b', emptyColor: '#d1d5db' },
}
Icon Variety
The icon option accepts any name from the Widgemo icon registry. Use color for filled icons and emptyColor for the unfilled remainder.
Stars, hearts, dollar signs, diamonds, and filled circles — each with matching filled/empty color pairs.
// Hearts — satisfaction or NPS
{ renderAs: 'rating', renderAsOptions: { icon: 'heart', color: '#e11d48', emptyColor: '#fecdd3' } }
// Dollar signs — budget tier or spend level
{ renderAs: 'rating', renderAsOptions: { icon: 'dollar', color: '#16a34a', emptyColor: '#d1fae5' } }
// Diamonds — tier / premium indicator
{ renderAs: 'rating', renderAsOptions: { icon: 'diamond', color: '#0ea5e9', emptyColor: '#bae6fd' } }
// Filled circles — confidence dots
{ renderAs: 'rating', renderAsOptions: { icon: 'circle-fill', color: '#6d28d9', emptyColor: '#ede9fe' } }
Custom Scale
max is not limited to 5. Use 3 for a simple Low/Medium/High or 10 for a finer-grained scale.
Same value rendered at max=3, max=5, and max=10 with different icons.
{ renderAsOptions: { max: 3, icon: 'star', color: '#f59e0b' } } // 3-point scale
{ renderAsOptions: { max: 5, icon: 'star', color: '#f59e0b' } } // 5-point scale (default)
{ renderAsOptions: { max: 10, icon: 'heart', color: '#e11d48' } } // 10-point scale
Options Reference
| Option | Type | Default | Effect |
|---|---|---|---|
max | number | (entity) => number | 5 | Total number of icons (filled + empty). |
size | number | CSS string | (entity) => ... | 16 | Icon size in px. |
icon | string | (entity) => string | 'star' | Icon name from the Widgemo icon registry. |
color | string | (entity) => string | '#ffc107' | Color of filled icons. |
emptyColor | string | (entity) => string | '#e4e5e9' | Color of empty icons. |
className | string | unset | Additional CSS class on the root element. |
The icon option accepts any name from the icon registry — see the Icons reference for the full list of built-in names and aliases. Custom icons registered via registerWidgemoIcon also work here — see Custom Icons.
Caveats
- Values are floored to the nearest integer —
4.7renders as 4 filled icons. - Values greater than
maxfill all icons without error. - Unrecognized icon names render nothing — the slot is present but invisible. Check the icon name against the registry if icons are missing.
emptyColorshould have low contrast against your background so filled icons stand out. Use a light tint of thecolorvalue (e.g.#fecdd3for a red#e11d48).
See Also
- scoreMeter Renderer — continuous meter with banded labels
- number Field Type
- Field Config