Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using image as Radio button in React JS

I want to use images as radio buttons but couldn't find any source. Any help will be appreciated.

sample of radio button with images

like image 254
touchngo Avatar asked Oct 23 '25 06:10

touchngo


2 Answers

It's easy, simply replace the text in the label with the image you want to add. for example:

<FormControlLabel
              value="paypal"
              control={<Radio />}
              label={<img src="https://assets.stickpng.com/images/580b57fcd9996e24bc43c530.png" alt="paypal" style={{width: "80px"}} />}
            /> 

Here I'm using radio buttons of MUI

like image 177
Someone Avatar answered Oct 24 '25 18:10

Someone


You need to first hide your [type=radio] and then wrap your image and the input tag inside the label.

This Stack Overflow link can be helpful

like image 36
Neel Dsouza Avatar answered Oct 24 '25 19:10

Neel Dsouza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!