Day 27 of 50 Days of React: Radio and Checkbox Component of MUI in React.

Aman Khan
2 min readAug 18, 2022

Hi, Dev’s👋🏻, Let’s see How to use the Button and Button Group Component of MUI in React?

Checkbox

Checkboxes allow the user to select one or more items from a set.

Checkboxes can be used to turn an option on or off.

If you have multiple options appearing in a list, you can preserve space by using checkboxes instead of on/off switches. If you have a single option, avoid using a checkbox and use an on/off switch instead.

import * as React from 'react';
import Checkbox from '
@mui/material/Checkbox';
const label = { inputProps: { 'aria-label': 'Checkbox demo' } };export default function Checkboxes() {
return (
<div>
<Checkbox {...label} defaultChecked />
<Checkbox {...label} />
<Checkbox {...label} disabled />
<Checkbox {...label} disabled checked />
</div>
);
}

Radio

Radio buttons allow the user to select one option from a set.

Use radio buttons when the user needs to see all available options. If available options can be collapsed, consider using a Select component because it uses less space.

Radio buttons should have the most commonly used option selected by default.

import * as React from 'react';
import Radio from '
@mui/material/Radio';
import RadioGroup from '
@mui/material/RadioGroup';
import FormControlLabel from '
@mui/material/FormControlLabel';
import FormControl from '
@mui/material/FormControl';
import FormLabel from '
@mui/material/FormLabel';
export default function RadioButtonsGroup() {
return (
<FormControl>
<FormLabel id="demo-radio-buttons-group-label">Gender</FormLabel>
<RadioGroup
aria-labelledby="demo-radio-buttons-group-label"
defaultValue="female"
name="radio-buttons-group"
>
<FormControlLabel value="female" control={<Radio />} label="Female" />
<FormControlLabel value="male" control={<Radio />} label="Male" />
<FormControlLabel value="other" control={<Radio />} label="Other" />
</RadioGroup>
</FormControl>
);
}

In the Next Article, I will be writing about How to use Rating and Select of MUI in React🤔?

That’s all for Today, Stay Tuned and I will see you in the next one👋🏻.

Thanks for Following and Claps😋

--

--

Aman Khan

Blockchain and Web3 Engineer Crafting compelling stories at the intersection of tech, business, and culture.