@alptugidin/react-circular-progress-bar

中文文档
1.1.4发布于 2024/09/06MITTypeScriptESM + CJS零依赖近 30 天下载 2397

A customizable circular progress bar for React.

原始使用文档
文档目录10 节
  1. Flat
  2. Props
  3. Styling
  4. Heat
  5. Props
  6. Styling
  7. Nested
  8. Props
  9. Styling
  10. Licence

A customizable circular progress bar for React.

Demo


npm



Installation

npm install @alptugidin/react-circular-progress-bar

or

yarn add @alptugidin/react-circular-progress-bar

Import

import {Flat, Heat, Nested} from '@alptugidin/react-circular-progress-bar'

Usage

Flat

<Flat  
   progress={50}
   range={{ from: 0, to: 100 }}
   sign={{ value: '%', position: 'end' }}
   text={'Match'}
   showMiniCircle={true}
   showValue={true}
   sx={{
     strokeColor: '#ff0000',
     barWidth: 5, 
     bgStrokeColor: '#ffffff',
     bgColor: { value: '#000000', transparency: '20' },  
     shape: 'full',
     strokeLinecap: 'round',
     valueSize: 13,
     valueWeight: 'bold',
     valueColor: '#000000',
     valueFamily: 'Trebuchet MS',
     textSize: 13,
     textWeight: 'bold',
     textColor: '#000000',
     textFamily: 'Trebuchet MS',
     loadingTime: 1000,
     miniCircleColor: '#ff0000',
     miniCircleSize: 5,
     valueAnimation: true,
     intersectionEnabled: true
   }}
/>

Props

Prop nameTypeRequiredDescription
progressnumberYesThe progress value of the progress bar, ranging from 0 to 100.
rangeobjectNoAn object containing the from and to values for the progress bar. The default value is { from: 0, to: 100 }.
signobjectNoAn object containing the value and position for the sign displayed in the progress bar. The value can be a string, and the position can be either 'start' or 'end'. The default value is { value: '%', position: 'end' }.
textstringNoThe text displayed above the progress bar.
showMiniCirclebooleanNoA flag indicating whether to show a mini circle at the end of the progress bar. The default value is true.
showValuebooleanNoA flag indicating whether to show the progress value in the progress bar. The default value is true.
sxobjectNoAn object containing CSS styles for customizing the appearance of the progress bar.

Styling

PropertyTypeDescription
barWidthnumberThe width of the progress bar.
strokeColorstringThe color of the active progress bar.
bgStrokeColorstringThe color of the background progress bar.
bgColorobjectThe color of the background progress bar. It has two properties: value: hex color and transparency: number between 00-99 (as string)
shapestringThe shape of the progress bar. Can be 'full', 'half' or 'threequarters'.
strokeLinecapstringThe line cap style of the progress bar. Can be 'butt', 'round', or 'square'.
valueSizenumberThe font size of the progress value.
valueWeightstringThe font weight of the progress value.
valueColorstringThe color of the progress value.
valueFamilystringThe font family of the progress value.
textSizenumberThe font size of the text above the progress bar.
textWeightstringThe font weight of the text above the progress bar.
textColorstringThe color of the text above the progress bar.
textFamilystringThe font family of the text above the progress bar.
loadingTimenumberThe time it takes for the progress bar to animate from 0 to the specified progress value.
miniCircleColorstringThe color of the mini circle at the end of the progress bar.
miniCircleSizenumberThe size of the mini circle at the end of the progress bar.
valueAnimationbooleanA flag indicating whether to animate the progress value.
intersectionEnabledbooleanA flag indicating whether to use an intersection observer to only start loading the progress bar when it becomes visible on the screen. The default value is true.

Heat

<Heat
  progress={50}
  range ={{ from: 0, to: 100 }}
  sign={{ value: '%', position: 'end' }}
  showValue={true}
  revertBackground={false}
  text={'Match'}
  sx={{
    barWidth: 5,
    bgColor: '#dadada',
    shape: 'half',
    valueSize: 13,
    textSize: 13,
    valueFamily: 'Trebuchet MS',
    textFamily: 'Trebuchet MS',
    valueWeight: 'normal',
    textWeight: 'normal',
    textColor: '#000000',
    valueColor: '#000000',
    loadingTime: 1000,
    strokeLinecap: 'round',
    valueAnimation: true,
    intersectionEnabled: true
  }}
/>

Props

PropTypeDescription
progressnumberThe progress value of the progress bar, ranging from 0 to 100.
rangeobjectAn object containing the from and to values for the progress bar. The default value is { from: 0, to: 100 }.
signobjectAn object containing the value and position for the sign displayed in the progress bar. The value can be a string, and the position can be either 'start' or 'end'. The default value is { value: '%', position: 'end' }.
showValuebooleanA flag indicating whether to show the progress value in the progress bar. The default value is true.
revertBackgroundbooleanA flag indicating whether to invert the colors of the progress bar. If true, the background color will start as red and gradually turn green as the progress value increases. The default value is false.
textstringThe text displayed above the progress bar.
sxobjectAn object containing CSS styles for customizing the appearance of the progress bar.

Styling

PropertyTypeDescription
barWidthnumberThe width of the progress bar.
bgColorstringThe background color of the progress bar.
shapestringThe shape of the progress bar. Can be 'full' or 'half'.
valueSizenumberThe font size of the progress value.
textSizenumberThe font size of the text above the progress bar.
valueFamilystringThe font family of the progress value.
textFamilystringThe font family of the text above the progress bar.
valueWeightstringThe font weight of the progress value.
textWeightstringThe font weight of the text above the progress bar.
textColorstringThe color of the text above the progress bar.
valueColorstringThe color of the progress value.
loadingTimenumberThe time it takes for the progress bar to animate from 0 to the specified progress value.
strokeLinecapstringThe line cap style of the progress bar. Can be 'butt', 'round', or 'square'.
valueAnimationbooleanA flag indicating whether to animate the progress value.
intersectionEnabledbooleanA flag indicating whether to use an intersection observer to only start loading the progress bar when it becomes visible on the screen. The default value is true.

Nested

<Nested
  circles={[
    {text: 'Javascript', value: 20, color: '#fde047'},
    {text: 'Typescript' ,value: 50, color: '#0ea5e9'},
    {text: 'HTML', value: 8, color: '#c2410c'},
    {text: 'CSS', value: 12, color: '#7c3aed'},
    {text: 'SASS', value: 10, color: '#c026d3'}
  ]}
  sx={{
    bgColor: '#cbd5e1',
    fontWeight: 'bold',
    fontFamily: 'Trebuchet MS',
    strokeLinecap: 'round',
    loadingTime: 1000,
    valueAnimation: true,
    intersectionEnabled: true
  }}
/>

Props

PropTypeDescription
circlesarrayAn array of objects containing the properties for each circle in the nested progress bar. Each object should have a text string, a value number, and a color string. Must have at least two circles. Can be up to 5.
sxobjectAn object containing CSS styles for customizing the appearance of the nested progress bar.

Styling

PropertyTypeDescription
bgColorstringThe background color of the nested progress bar.
fontWeightstringThe font weight of the text in the nested progress bar.
fontFamilystringThe font family of the text in the nested progress bar.
strokeLinecapstringThe line cap style of the circles in the nested progress bar. Can be 'butt', 'round', or 'square'.
loadingTimenumberThe time it takes for the circles in the nested progress bar to animate from 0 to their specified values.
valueAnimationbooleanA flag indicating whether to animate the values in the circles of the nested progress bar.
intersectionEnabledbooleanA flag indicating whether to use an intersection observer to only start loading the nested progress bar when it becomes visible on the screen. The default value is true.

Licence

MIT Alptuğ İdin

版本与发布记录

@alptugidin/react-circular-progress-bar 共发布 7 个版本,首次发布于 2022/12/30;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.4latest2024/09/062 年前
1.1.32024/09/062 年前
1.1.22023/12/172 年前
1.1.12023/12/172 年前
1.1.02023/01/203 年前
1.0.12022/12/303 年前

关于 @alptugidin/react-circular-progress-bar 的常见问题

@alptugidin/react-circular-progress-bar 是什么?

A customizable circular progress bar for React.

如何安装 @alptugidin/react-circular-progress-bar?

在项目目录运行 npm install @alptugidin/react-circular-progress-bar,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18.0.0)、react-dom(>=18.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@alptugidin/react-circular-progress-bar 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@alptugidin/react-circular-progress-bar 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@alptugidin/react-circular-progress-bar 可以商用吗?

@alptugidin/react-circular-progress-bar 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@alptugidin/react-circular-progress-bar 的下载量有多少?

根据 npm 官方下载统计,@alptugidin/react-circular-progress-bar 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,397 次,日均约 80 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@alptugidin/react-circular-progress-bar 还在维护吗?

最新版本 1.1.4 发布于 2024/09/06(2 年前);至今共发布 7 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/12/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。