Search results

Customize RadioButton Appearance

You can customize the appearance of the RadioButton component by using the CSS rules. Define own CSS rules according to your requirement and assign the class name to the cssClass property.

The background and border color of the RadioButton is customized through the custom classes to create the primary, success, warning, danger, and info type of radio button.

Source
Preview
app.tsx
index.html
index.css
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { RadioButtonComponent } from '@syncfusion/ej2-react-buttons';
// To customize RadioButton appearance.
class App extends React.Component<{}, {}> {
  render() {
    return (
        <ul>
            {/* Refer the 'e-primary' class details in 'style.css'.*/}
            <li><RadioButtonComponent label="Primary" cssClass="e-primary" name="custom" /></li>

            {/* Refer the 'e-success' class details in 'style.css'.*/}
            <li><RadioButtonComponent label="Success" cssClass="e-success" name="custom" /></li>

            {/* Refer the 'e-info' class details in 'style.css'.*/}
            <li><RadioButtonComponent label="Info" cssClass="e-info" checked={true} name="custom" /></li>

            {/* Refer the 'e-warning' class details in 'style.css'.*/}
            <li><RadioButtonComponent label="Warning" cssClass="e-warning" name="custom" /></li>

            {/* Refer the 'e-danger' class details in 'style.css'.*/}
            <li><RadioButtonComponent label="Danger" cssClass="e-danger" name="custom" /></li>
        </ul>
    );
  }
}
ReactDom.render(<App />, document.getElementById('radio-button'));
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Button</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-buttons/styles/material.css" rel="stylesheet" />
	<link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
        <div id='radio-button'>
            <div id='loader'>Loading....</div>
        </div>
</body>

</html>
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}

.e-radio-wrap {
  margin-top: 18px;
}

.e-radio:checked + .e-success::after { /* csslint allow: adjoining-classes */
  background-color: #689f38;
}

.e-radio:checked:focus + .e-success::after, .e-radio:checked + .e-success:hover::after { /* csslint allow: adjoining-classes */
  background-color: #449d44;
}

.e-radio:checked + .e-success::before {
  border-color: #689f38;
}

.e-radio:checked:focus + .e-success::before, .e-radio:checked + .e-success:hover::before { /* csslint allow: adjoining-classes */
  border-color: #449d44;
}

.e-radio +.e-success:hover::before {
  border-color: #b1afaf
}
.e-radio:checked + .e-info::after { /* csslint allow: adjoining-classes */
  background-color: #2196f3;
}

.e-radio:checked:focus + .e-info::after, .e-radio:checked + .e-info:hover::after { /* csslint allow: adjoining-classes */
  background-color: #0b7dda;
}

.e-radio:checked + .e-info::before {
  border-color: #2196f3;
}

.e-radio:checked:focus + .e-info::before, .e-radio:checked + .e-info:hover::before {
  border-color: #0b7dda;
}

.e-radio + .e-info:hover::before {
  border-color: #b1afaf
}

.e-radio:checked + .e-warning::after { /* csslint allow: adjoining-classes */
  background-color: #ef6c00;
}

.e-radio:checked:focus + .e-warning::after, .e-radio:checked + .e-warning:hover::after { /* csslint allow: adjoining-classes */
  background-color: #cc5c00;
}

.e-radio:checked + .e-warning::before {
  border-color: #ef6c00;
}

.e-radio:checked:focus + .e-warning::before, .e-radio:checked + .e-warning:hover::before {
  border-color: #cc5c00;
}

.e-radio + .e-warning:hover::before {
  border-color: #b1afaf
}

.e-radio:checked + .e-danger::after { /* csslint allow: adjoining-classes */
  background-color: #d84315;
}
.e-radio:checked:focus + .e-danger::after, .e-radio:checked + .e-danger:hover::after { /* csslint allow: adjoining-classes */
  background-color: #ba330a;
}

.e-radio:checked + .e-danger::before {
  border-color: #d84315;
}

.e-radio:checked:focus + .e-danger::before, .e-radio:checked + .e-danger:hover::before {
  border-color: #ba330a;
}

.e-radio + .e-danger:hover::before {
  border-color: #b1afaf
}

li {
  list-style: none;
  margin: 25px auto;
}