
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
react-styled-radio
Advanced tools
Radio button component for React built with styled-components < 💅>
Radio button component for React built with styled-components < 💅>
npm install --save react-styled-radio
yarn add react-styled-radio
import React, { Component } from 'react';
import { RadioGroup, Radio } from 'react-styled-radio';
class Example extends Component {
render () {
return (
<RadioGroup horizontal name="gender">
<Radio small value="male" label="male"/>
<Radio small value="female" label="female"/>
</RadioGroup>
)
}
}
The RadioGroup component accepts the following props.
Prop | Type | Default | Description: Options |
---|---|---|---|
vertical | boolean | false | Display radios vertically |
onChange | function | null | Function to run when value changes |
The Radio component accepts the following props.
Prop | Type | Default | Description: Options |
---|---|---|---|
small | boolean | false | Button size |
large | boolean | false | Button size |
handleChange | function | null | Function to run when value changes |
The handleChange prop is automatically passed the event object. See below example.
class Example extends Component {
onChange = e => {
console.log(e.target.value)
/*
If the first radio is clicked this will log 'male'
If the second radio is clicked this will log 'female'
*/
}
render () {
return (
<RadioGroup horizontal name="gender" onChange={this.onChange}>
<Radio small value="male" label="male"/>
<Radio small value="female" label="female"/>
</RadioGroup>
)
}
}
The theme object can be used to customize the look of the components, with the following values.
Prop | Type | Default |
---|---|---|
inputBg | string | #20232A |
inputBorder | string | #292C34 |
inputColor | string | #212529 |
inputPlace | string | #6B757C |
inputOutline | string | #007BFF |
inputLabel | string | #212529 |
There are two ways to use the theme object.
import { ThemeProvider } from 'styled-components';
...
return (
<ThemeProvider theme={theme}>
<RadioGroup horizontal name="gender" handleChange={this.handleChange}>
<Radio small value="male" label="male"/>
<Radio small value="female" label="female"/>
</RadioGroup>
</ThemeProvider>
);
...
...
return (
<RadioGroup horizontal name="gender" handleChange={this.handleChange}>
<Radio theme={theme} small value="male" label="male"/>
<Radio theme={theme} small value="female" label="female"/>
</RadioGroup>
);
...
Class | Description |
---|---|
.radio__group | Radio group wrapper |
.radio__button | Radio button wrapper |
.radio__text | Radio button label |
Follow these steps to setup a local development environment. Use yarn or npm - not both.
git clone https://github.com/alexcasche/react-styled-radio
npm install && npm start
yarn install && yarn add
cd example
npm install && npm start
yarn install && yarn start
MIT © alexcasche
FAQs
Radio button component for React built with styled-components < 💅>
The npm package react-styled-radio receives a total of 7 weekly downloads. As such, react-styled-radio popularity was classified as not popular.
We found that react-styled-radio demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.