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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-multi-progress

v1.3.0

Published

![alt text](docs/progressbar.png)

Downloads

7,508

Readme

react-multi-progress

alt text

A simple, typed react progress bar that allowes multiple layers in different colors. Demo

Installation

Install with npm:

  • npm install react-multi-progress --save

You can now import react-multi-progress as a normal package installed from npm like so:

import MultiProgress from 'react-multi-progress'
...

You can also import the type definitions if you're using TypeScript like so:

import MultiProgress, { IMultiProgressProps } from 'react-multi-progress'
...

Available props

| Attribute | Type | Optional | Default | Description | | :------------------------- | :-------------------: | :------: | :---------------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | backgroundColor | string | yes | #ffffff | Background color of the progress bar | | border | string | yes | none | set a border around the progress bar, e.g. 1px solid red | | elements | ProgressElement[] | no | none | Set the color and size of each element, see "ProgressElement" below. | | height | number | yes | 10 | Height of the progress bar in px | | round | bool | yes | true | Wheter the ends of the progress bar container should be rounded | | roundLastElement | bool | yes | true | Wheter the last progress element should be rounded on the right end | | transitionTime | number | yes | 0.6 | Transition time in seconds to animate when the value changes. Set to 0 for no animation. | | className | string | yes | | CSS className passed onto the ProgressBar Container | | component | ElementType | yes | div | Custom element used to render progress elements, either a HTML tag name or React component accepting className, children, and element props, with element being the ProgressElement passed in. Be sure to spread the remaining props (see example) as style information is provided in this way (a data attribute) | | type generic (see example) | Record<string, any> | yes | Record<string, never> | Additional props to add to the definition of elements, for use with custom components |

ProgressElement

| Attribute | Type | Optional | Description | | :------------- | :------: | :------: | :------------------------------------------------------- | | value | number | no | Length of the element in % (0-100) | | color | string | no | Color of the element (any css compatible format) | | showPercentage | bool | yes | Show the percentage as text in the ProgressElement | | textColor | string | yes | Color of the percentage text (any css compatible format) | | fontSize | number | yes | font size of the percentage text (in px) | | className | string | yes | CSS className passed onto the ProgressElement |

Example

Basic

import MultiProgress from "react-multi-progress";

function Progress() {
	return (
		<MultiProgress
			elements={[
				{
					value: 35,
					color: "blue",
				},
			]}
		/>
	);
}

Advanced

import MultiProgress, { ProgressComponentProps } from "react-multi-progress";

// for non-TS projects, remove this and other types
type ExtraData = { isBold: boolean };

function CustomComponent({
	children,
	element,
	...rest
}: ProgressComponentProps<ExtraData>) {
	return (
		<div
			{...rest} // adds all styles for rendering the progress bar
			style={{
				fontWeight: element.isBold ? 900 : 300,
			}}
		>
			{children}
		</div>
	);
}

function Progress() {
	return (
		<MultiProgress<ExtraData>
			transitionTime={1.2}
			elements={[
				{
					value: 15,
					color: "blue",
					isBold: false,
				},
				{
					value: 35,
					color: "rgb(100,0,0)",
					showPercentage: true,
					fontSize: 12,
					textColor: "white",
					isBold: true,
				},
				{
					value: 25,
					color: "black",
					showPercentage: true,
					textColor: "white",
					fontSize: 12,
					isBold: false,
					className: "my-custom-css-class",
				},
			]}
			height={15}
			backgroundColor="gray"
			border="1px solid red"
			className="my-custom-css-class"
			component={CustomComponent}
		/>
	);
}