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

react-radio-button

v1.5.4

Published

A react radio button component with an additional pinch of CSS applied.

Downloads

94

Readme

react-radio-button

npm: This react component is a div based radio button group. Simple to use and access.

How to install:

npm install react-radio-button

Example:

Example Image

Usage:

import React, { Component, PropTypes } from 'react';

import RadioButtonGroup from 'react-radio-button';

export default class App extends Component {

	constructor(props) {
		super(props);
		this.state = {
			selectedValue: undefined,
			radioOptions: [
				{ value: 'CreditCard', text: 'Credit Card' },
				{ value: 'DebitCard', text: 'Debit Card'}
			]
		};
	}

	handleSelection(value) {
		this.setState({selectedValue: value});
	}

  render() {
    return (
      <div className="container">
        <div className="row">
          <div className="col-xs-12">
      	    <h2> Welcome for the radio button example</h2>
      	  </div>
      	  <div className="col-xs-12">
      	    <RadioButtonGroup listOfItems={this.state.radioOptions} selectedItemCallback={(value) => this.handleSelection(value)}/>
      	  </div>
      	  <div className="col-xs-12">
      	    <h4>Selected radio button: <i>{this.state.selectedValue}</i></h4>
      	  </div>
      	</div>
      </div>
    );
  }
}

###props to the <RadioButtonGroup listOfItems={<items>} selectedItemCallback={callbck} />

###listOfItems (PropTypes.array): The items that need to appear on the radio items, is in the format (array): javascript radioOptions: [ { value: 'CreditCard', text: 'Credit Card' }, { value: 'DebitCard', text: 'Debit Card'} ] where, value is the value we get on radio button selection text is the display of the radio button

###selectedItemCallback (PropTypes.func) The callback that is invoked when a radio button is clicked (function): (value) => handleSelection(value) where,

  handleSelection(value) {  //value is the selected value, like "CreditCard" or "DebitCard"
      this.setState({selectedValue: value});
  }

##Customing button colors (The default colors are shown below):

Add these to your custom css file and should be ideally changing the color for which ever color scheme you use.

###With not selected state:

.not-checked {
    background-color: #ffffff !important;
    border-color: #ccc !important;
}

###With selected state:

.checked {
    background-color: #7d9c47 !important;
}

.radio-button-item > input[type="radio"]:checked+span:after {
  background-color: #426C2A !important;
}

.radio-button-item > input[type="radio"]:checked+span+span{
    color: #fff !important;
}

###On hover, the color to change:

.radio-button-item:hover .radio-dot:before {
    border-color: #bdde85 !important;
}

.radio-button-item:hover .radio-dot:after {
    background-color: #bef65b !important;
}

Once added to a custom css file (example: test.css), do import the same as:

import React, { Component, PropTypes } from 'react';

import RadioButtonGroup from '~/components/RadioButtonGroup';
import './test.css'  // Relative path