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

DiffStat

diff-stat

Summarizes added and removed lines with proportional bars and file-status badges.

Usage

Basic usage

+N −M Number + green and red grid bars filled according to the addition and deletion ratio, PR is just needed for list/code review.

+24−6
tsx
<DiffStat additions={24} deletions={6} />

Status Logo

status Rendering Add/Modify/Delete/Rename Logo (renamed Borrow primary Blue Difference modified).

Added+142−0Modified+24−6Deleted+0−88Renamed+3−3
tsx
<>
  <DiffStat additions={142} deletions={0} status="added" />
  <DiffStat additions={24} deletions={6} status="modified" />
  <DiffStat additions={0} deletions={88} status="deleted" />
  <DiffStat additions={3} deletions={3} status="renamed" />
</>

Grid strips only

showCounts={false} hides the numbers, leaving only compact green and red grid bars.

tsx
<DiffStat additions={7} deletions={2} showCounts={false} />

Size

size="sm" Reduce the grid and follow the text within the line.

+10−4+10−4
tsx
<>
  <DiffStat additions={10} deletions={4} size="sm" />
  <DiffStat additions={10} deletions={4} size="md" />
</>

When to use

Use DiffStat in pull-request or commit lists to summarize a file's additions, deletions, and change status. Use Sparkline for trends or FileTree for hierarchical changed-file navigation.

Import

ts
import { DiffStat, splitBlocks } from "@hulianui/ui"

Props

NameTypeDefaultDescription
additions*number-Number of added lines.
deletions*number-Number of deleted lines.
status"added" | "modified" | "deleted" | "renamed"-Optional file-status badge.
blocksnumber5Total number of proportional blocks.
showCountsbooleantrueShows the addition and deletion counts.
size"sm" | "md""md"Component size.
classNamestring-Custom class name.

Pitfalls

The bar divides blocks according to the additions:deletions ratio through the pure splitBlocks helper. When both counts are zero, the bar remains empty.

Status badge accessibility text remains Chinese at runtime: "\u65b0\u589e" ("Added"), "\u4fee\u6539" ("Modified"), "\u5220\u9664" ("Deleted"), and "\u91cd\u547d\u540d" ("Renamed").

Related

Status badges follow ConfigProvider. DiffStat is a client component; server components can still import and render it.
Sparkline · ImageViewer · LiveProductCard · ScoreRing · Badge · Dot

Playground

Modified+24−6
<DiffStat additions={24} deletions={6} status="modified" blocks={5} />
PreviousFileTreeData DisplayNextScoreRing

On this page

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