0

I was wondering whether it is possible to fill a parent button with a radio button and remove the default radio button styling, keeping the radio button functionality for the button.

<button>
  <input type='radio' />
</button>
Luke Grech
  • 145
  • 2
  • 11
  • Why. What is the usecase? You can use JavaScript to set a hidden field when the button is clicked – mplungjan Nov 12 '21 at 09:10
  • Basically I am using Formik and Yup for input validation and need three separate radio buttons to select an input (wont work with buttons) – Luke Grech Nov 12 '21 at 09:13
  • Show the HTML and what it needs to do and we have a better idea. What is the problem you are trying to solve? It sounds like an X/Y problem – mplungjan Nov 12 '21 at 09:14
  • I just need a radio button (in a button as shown in the snippet) to fill an outer button styling. – Luke Grech Nov 12 '21 at 09:18

1 Answers1

0

Hopping this is the desired behavior, this is my solution:

button input[type="radio"] {
  /* Add if not using autoprefixer */
  -webkit-appearance: none;
  appearance: none;
  /* For iOS < 15 to remove gradient background */
  background-color: #fff;
  /* Not removed via appearance */
  margin: 0;
  width:100px;
}
<button>
  <input type='radio' />
</button>
D A
  • 1,724
  • 1
  • 8
  • 19