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

modern-react-dice-roll

v1.0.0

Published

A highly customizable dice roll package built in react.

Readme

Modern React Dice Roll

npm version License: MIT

A fully modernized and customizable dice roll component for React, forked from the original react-dice-roll.

This version has been completely reworked to support modern React (v17/18+), TypeScript, and current JavaScript tooling, eliminating the need for --legacy-peer-deps.

Key Features & Improvements

  • Modern React Support: Full compatibility with React 17, 18, and beyond.
  • TypeScript Native: Written entirely in TypeScript for full type safety and great developer experience.
  • No Legacy Dependencies: Installs cleanly in any modern project.
  • ESM & CJS Builds: Ships with both module formats for broad compatibility.
  • Feature Parity: Keeps all the features of the original package.

Installation

Install the package using your favorite package manager:

npm install modern-react-dice-roll

or

yarn add modern-react-dice-roll

Usage

Import the component and its stylesheet, then render it in your app.

import Dice from 'modern-react-dice-roll';
import 'modern-react-dice-roll/dist/index.css';

function MyComponent() {
  const handleRoll = (value) => {
    console.log(`You rolled a ${value}!`);
  };

  return (
    <div>
      <Dice onRoll={handleRoll} />
    </div>
  );
}

Props

Customize the dice component with these props:

| Prop | Type | Default | Description | | -------------- | -------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | onRoll | (value: 1-6) => void | undefined | Required. A function that receives the rolled value (1-6). | | size | number | 250 | The width and height of the dice in pixels. | | defaultValue | 1-6 | 6 | The value the dice shows before the first roll. | | rollingTime | number | 1000 | The duration of the rolling animation in milliseconds. | | disabled | boolean | false | If true, the dice is visually greyed out and cannot be rolled. | | cheatValue | 1-6 | undefined | If provided, the dice will always roll this value. | | triggers | string[] | ['click'] | An array of keyboard keys that trigger a roll. Use 'click' to enable mouse clicks. Example: ['Enter', 'r', 'click'] | | sound | string | undefined | A URL to a sound file to be played during the roll. | | faces | string[] | undefined | An array of 6 image URLs to use for custom dice faces, starting with face 1. | | faceBg | string | undefined | A custom background color for the dice faces. | | placement | 'top-left' \| 'top-right' \| 'bottom-left' \| 'bottom-right' | undefined | Positions the dice absolutely within a relatively-positioned parent element. Useful for overlaying the dice on other content. |

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT