npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sea-lion/react-progress

v0.3.0

Published

Progress 是一个进度指示器组件,用于显示操作完成的进度或加载状态。

Readme

react-progress

Progress 是一个进度指示器组件,用于显示操作完成的进度或加载状态。

安装

$ yarn add @sea-lion/react-progress
# 或者
$ npm install @sea-lion/react-progress

基本使用

import { Progress } from "@sea-lion/react-progress";

export default () => <Progress value={40} />;

不同尺寸

Progress 组件提供了三种尺寸:

<Progress size="1" value={60} />
<Progress size="2" value={60} /> {/* 默认尺寸 */}
<Progress size="3" value={60} />

不同变体

Progress 组件提供了三种变体样式:

<Progress variant="classic" value={60} />
<Progress variant="surface" value={60} /> {/* 默认样式 */}
<Progress variant="soft" value={60} />

自定义颜色

<Progress value={60} color="blue" />
<Progress value={60} color="green" />
<Progress value={60} color="red" />
<Progress value={60} color="purple" />
<Progress value={60} color="orange" />
<Progress value={60} color="amber" />

圆角设置

使用 radius 属性自定义进度条的圆角样式:

<Progress value={60} radius="none" />
<Progress value={60} radius="small" />
<Progress value={60} radius="medium" />
<Progress value={60} radius="large" />
<Progress value={60} radius="full" />

不确定状态

当不提供 value 属性时,Progress 会展示为不确定状态的加载指示器:

<Progress />
<Progress color="blue" />
<Progress color="green" />

自定义动画持续时间

<Progress duration="2s" />   {/* 快速 */}
<Progress duration="5s" />   {/* 默认 */}
<Progress duration="10s" />  {/* 缓慢 */}

高对比度模式

<Progress value={60} color="blue" />
<Progress value={60} color="blue" highContrast />

动态进度条

import { useState, useEffect } from "react";
import { Progress } from "@sea-lion/react-progress";

export default () => {
  const [progress, setProgress] = useState(0);
  const [isRunning, setIsRunning] = useState(false);

  useEffect(() => {
    let timer;
    if (isRunning) {
      timer = setInterval(() => {
        setProgress((prev) => {
          if (prev >= 100) { setIsRunning(false); return 100; }
          return prev + 5;
        });
      }, 300);
    }
    return () => clearInterval(timer);
  }, [isRunning]);

  return (
    <div>
      <Progress value={progress} />
      <button onClick={() => { setProgress(0); setIsRunning(true); }}>
        开始
      </button>
      <span>{progress}%</span>
    </div>
  );
};

实用场景

文件上传进度

<div>
  <Progress value={uploadProgress} color="blue" size="2" />
  <div style={{ display: 'flex', justifyContent: 'space-between' }}>
    <span>正在上传...</span>
    <span>{uploadProgress}%</span>
  </div>
</div>

加载状态

<div>
  <p>正在加载数据,请稍候...</p>
  <Progress color="purple" variant="surface" size="2" />
</div>

何时使用

  • 需要显示任务或操作的完成进度时
  • 需要表示加载状态或处理过程时
  • 展示文件上传、下载进度时
  • 需要给用户提供视觉反馈,表明任务正在进行中时

属性

| 参数 | 说明 | 类型 | 默认值 | | ------------ | ------------ | -------------------------------------------------- | --------- | | size | 进度条尺寸 | '1' | '2' | '3' | '2' | | variant | 变体样式 | 'classic' | 'surface' | 'soft' | 'surface' | | color | 颜色 | 标准颜色值 | - | | highContrast | 高对比度模式 | boolean | false | | radius | 圆角半径 | 'none' | 'small' | 'medium' | 'large' | 'full' | - | | duration | 动画持续时间 | ${number}s | ${number}ms | '5s' | | value | 当前进度值 | number | - | | max | 最大进度值 | number | 100 |

查看更多

参考 Radix UI 官方文档 获取完整 API 与设计规范。