Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

ScoreRing

score-ring

Displays a numeric score and grade inside a color-coded radial gauge.

Usage

Basic usage

value drive ring progress and center number, the default score is 100, and the A-F level word is displayed.

82
B
Quality points
tsx
<ScoreRing value={82} label="Quality Points" />

Grade bands

The default A-F grade is automatically selected according to the score: A excellent / B good / C passing / F failing.

95
A
Quality points
82
B
Quality points
68
D
Quality points
42
F
Quality points
tsx
<>
  <ScoreRing value={95} label="Quality Points" />
  <ScoreRing value={82} label="Quality Points" />
  <ScoreRing value={68} label="Quality Points" />
  <ScoreRing value={42} label="Quality Points" />
</>

Size and ring width

size controls the diameter, thickness controls the ring width; for small sizes, showGrade={false} only leaves numbers.

88
88
B
Quality points
88
B
Quality points
tsx
<>
  <ScoreRing value={88} size={48} thickness={5} showGrade={false} />
  <ScoreRing value={88} size={96} thickness={8} label="Quality Points" />
  <ScoreRing value={88} size={128} thickness={12} label="Quality Score" />
</>

When to use

Use ScoreRing to present a quality, health, or rating score as a circular gauge with automatic A-F grade coloring. Use [Meter] or [Progress] for linear progress and capacity, or Sparkline for trends. Its SVG dasharray rendering is compatible with React Server Components.

Import

ts
import { ScoreRing, resolveGrade, DEFAULT_GRADES } from "@hulianui/ui"

Props

Grade = { min: number; label: string; tone?: string }, where min is the **lowest score
(inclusive)** that lands in the band, label is the band's caption, and tone takes either a
semantic color name ("success" / "warning" / "danger" / "chart-2" and so on) or any CSS
color value (#hex, var(--color-success)). Both are typed string and both are accepted.

NameTypeDefaultDescription
value*number-Current score.
maxnumber100Maximum score.
gradesGrade[]-Grade bands; omission uses DEFAULT_GRADES for A-F.
sizenumber96Diameter in pixels.
thicknessnumber8Ring thickness in pixels.
showGradebooleantrueShows the grade letter.
decimalsnumber-Decimal places for the default formatted center value (when formatValue is omitted; defaults to Math.round(value)).
suffixReactNode-Suffix rendered after the default formatted center value, such as "%".
formatValue(value: number) => ReactNode-Custom center value formatter; takes precedence over decimals and suffix.
classNamestring-Custom class name.

Slots

SlotTypeDescription
labelReactNodeSecondary center label, such as "Quality score".

Pitfalls

  • resolveGrade(value, grades) determines the grade color. It takes two arguments and

there is no max: max is a prop this component uses to draw the arc, not a parameter of
the function. Before 0.56.1 this section claimed three arguments, and following it with
resolveGrade(score, 100, myGrades) passes 100 where grades belongs.

  • The default DEFAULT_GRADES has five bands but only three colors (A/B are both success,

C/D are both warning). Pass your own grades when every band needs its own color.

  • A band without tone falls back to the component's default color, not to transparent.

Give it an explicit color when a band should not be tinted.

Related

Sparkline · ImageViewer · LiveProductCard · DiffStat · Badge · Dot

Playground

82
B
Quality points
<ScoreRing value={82} size={96} thickness={8} label="Quality Points" />
PreviousDiffStatData DisplayNextScoreScale

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Slots
    • Pitfalls
    • Related
  • Playground