-3

I want to change the appearance of a Drupal 8 webform (version 8.x-5.8) radio element as per the options. Basically, the radio element is being visually presented as buttons and I was able to theme the buttons. However, this is a site where we are looking to collect responses from patients on their symptom severity and I would like to know if there is a way where I can color code the options like Red color for the button that says Severe, Blue Color that says Mild etc.

1
0

I achieved this using webform custom elements module. Copied the button type element and then in the HTML added the value to the button class such that button with value 1 will have a class .btn-1 and with value 2 will have a class .btn-2. Then applied different css background colors to the buttons.

Other sites mention that the value attribute can be used with css like this .btn[value="1"] to ensure that css styling can be customized as per button value but it did not seem to work in this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.