New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-dice-complete

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dice-complete

Create dice for any game and roll for totals. Complete UI and Logic

latest
Source
npmnpm
Version
2.2.0
Version published
Weekly downloads
176
23.94%
Maintainers
1
Weekly downloads
 
Created
Source

React Dice 🎲

npm version contributions welcome

Library for creating multisided dice and rolling them. Check out the demo here.

sample dice roll

Installation

npm install react-dice-complete

Usage

import React, { useRef } from 'react'
import ReactDice, { ReactDiceRef } from 'react-dice-complete'

const MyDiceApp = () => {

  const reactDice = useRef<ReactDiceRef>(null)

  const rollDone = (totalValue: number, values: number[]) => {
    console.log('individual die values array:', values)
    console.log('total dice value:', totalValue)
  }

  const rollAll = () => {
    reactDice.current?.rollAll()
  }

  return (
    <ReactDice
      numDice={2}
      ref={reactDice}
      rollDone={rollDone}
    />
  )

}

Available Options

NameTypeDefaultDescription
defaultRoll{Number}6The number you want displayed before a roll
dieCornerRadius{Number}5Rounded radius to use for each die
dieSize{Number}60px width/height of each dice face
disableIndividual{Bool}falsedisable clicks on die to roll each individually
disabbleRandom{Bool}falsedisable random die chance and reuses current value
dotColor{String}#1eff00hex color code for the dots on the die
faceColor{String}#ff00achex color code for the face of the die
margin{Number}15margin between each die
numDice{Number}4The number of dice you wish to have
outline{Bool}falseShow a 1px outline for each face of the die
outlineColor{String}#000000hex color code for outline color if outline is true
rollDone{String/Function}nullcallback returns total & individual values from dice roll
rollTime{Number}2time in seconds for the roll animation

Provided functions

rollAll([values]): rolls all die and calls rollDone with total from roll. You can preset the values you would like the outcome to be by passing array of numbers, if not result will be random.

Keywords

die

FAQs

Package last updated on 12 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts