Customize the appearance of radio buttons with unique colored outer and inner circles

I am in need of creating a MUI radio button that features a unique outer ring color compared to the selected inner fill color.

Although I have reviewed the official documentation, it appears that customization options only allow for changing the color as a whole or using custom icons within the element itself.

Could there be an obvious styling solution that I'm overlooking, or is achieving this seemingly simple task more complex than anticipated?

Answer №1

To achieve a unique look with the ring and inner fill, I utilized the :after and :before pseudo-elements. In this instance, I experimented with a green border and red inner fill:

  <Radio
    {...controlProps("d")}
    sx={{
      color: "green",
      "&.Mui-checked": {
        position: "relative",
        "&::before": {
          content: '""',
          position: "absolute",
          top: "50%",
          left: "50%",
          transform: "translate(-50%, -50%)",
          width: "10px",
          height: "10px",
          borderRadius: "50%",
          backgroundColor: "white"
        },
        "&::after": {
          content: '""',
          position: "absolute",
          top: "50%",
          left: "50%",
          transform: "translate(-50%, -50%)",
          width: "10px",
          height: "10px",
          borderRadius: "50%",
          backgroundColor: "red",
          opacity: 1,
          borderColor:"red"
        },
        "&.Mui-checked::after": {
          opacity: 1
        }
      }
    }}
  />

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to tackle the issue of responsive layout

I'm facing an issue with this code snippet that I'm using for responsive layout. When I test it on my computer using programming tools to view how the code looks on a phone-sized screen, it appears perfect. However, when I deploy it, it doesn&apo ...

Is there a way to dynamically assign the background color of a webpage based on the exact width and height of the user's screen?

I have customized the CSS of my website by setting the height to 800px and width to 1050px. Additionally, I have chosen a blue background-color for the body tag. It is important that the entire application adheres to these dimensions. However, when viewe ...

The web browser shows a 404 error for HTTP requests, while Postman successfully processes them without any

I have successfully deployed my app on Heroku and everything seems to be working correctly, except for when I try to submit a POST request to sign up or log in a user. I keep getting a 404 error. Interestingly, I don't encounter this issue when using ...

Expanding a website banner slide to fill the entire width of the page

Is there a way to ensure that the banner images in the website below flow seamlessly? Currently, it seems like the current image is cut off on the left and part of the previous image shows up in its place. I'd like the current image to occupy the ent ...

To optimize your bundling process, include the leaflet.css file from the node_modules/leaflet directory using webpack

Currently, I am working on developing a map application using webpack and leaflet. While I can successfully require leaflet.js from my map.js file, I encounter an error when trying to call leaflet.css. The configuration in my webpack.config.js is as follo ...

Ways to make the Select component in Material-UI lose its focus state once an item has been selected

Anticipated outcome: Upon selecting an item, the Menu list will promptly close, and the Select component will no longer display a focus state. The borderBottom will change to 1px solid, and the backgroundColor will turn to white. Current situation: Sele ...

The background of an HTML button does not appear in IE8

My buttons are not showing up in IE8. I tried adding background: transparent url('..'), but it didn't help. Here is the code: .wpcf7 input.wpcf7-submit { background: url("/wp-content/themes/ASC/images/<?=ICL_LANGUAGE_CODE;?>_submi ...

Getting the external IP address in an Axios request with NodeJS

Is there a way to retrieve the resolved IP address of a remote URL in Node.js by using axios? Please refer to the comment provided below. Thank you in advance! axios.get('http://www.example.com') .then(function (response) { // *** Lookin ...

Tips for resolving Typescript type error when overriding MuiContainer classes

My application is divided into two main files: (https://codesandbox.io/s/react-ts-muicontainer-override-yywh2) //index.tsx import * as React from "react"; import { render } from "react-dom"; import { MuiThemeProvider } from "@material-ui/core/styles"; imp ...

Is there a way to configure my dropdown menu so that only one dropdown can be open at a time and it remains open when clicking on a <li> item?

I've been working on developing a dropdown menu that appears when clicked, rather than hovered over. I've managed to implement this functionality using JavaScript, and overall, it's working quite well. Currently, the menu shows or hides whe ...

Getting the response values in ReactJs is a crucial step for successful handling of

Hello everyone, I'm fairly new to React development and facing some challenges with fetching data from my JSON response. axios.get('http://localhost:9000/test') .then(function (response) { console.log(response.data.name); console.lo ...

Having difficulty adjusting certain internal styles within Material UI's <Dialog> component

I want to customize the styling of my <Dialog> component by adding rounded corners using a border radius. Here is the inline style I am trying to apply to override the default styles of the <Dialog>: let overrideStyles = { padding: 0, marg ...

What is the best way to showcase text formatting applied in Strapi's WYSIWYG editor in NextJS's user interface?

I'm a beginner with Next JS and Strapi CMS. Trying to figure out how to transfer styling from the backend admin panel in Strapi to the UI in NextJS. Is there a way to display the formatted text created in Strapi's WYSIWYG editor on the frontend ...

The function is not being called as expected when using `onclick` or `eventListener('click')`

I'm in the process of developing a login form for my website that will offer 2 options - "login" and "signup". The concept is similar to mini tabs and iframe windows. Essentially, I have two divs side by side for "login" and "signup". When the user cl ...

Invoke a router inside Node.js once a route has been triggered

I am working with ExpressJS and integrating the Auth0 API for authentication, along with ReactJS on the client side. Due to some limitations of the Auth0 API that I discussed with their team, I have implemented a workaround where I send updated user detail ...

Trying to transfer data from a child component to a parent component in a Firebase-powered React application

Currently in the process of constructing a React Firebase blog and my objective is to transfer {color} from the ViewPosts component (child) to the App component (parent). This is an overview of the App: function App() { const [backgroundColor, setBackg ...

What is the best way to transfer data from a div tag to an li tag using JavaScript?

https://i.stack.imgur.com/se2qk.pngI am attempting to change the div tag content to li tag. Here is a snippet of the code from inspect for reference. I need to remove the div tag with the "domTitle" class. <li style="display: inline;" id="list_name"> ...

Utilizing the useRef hook in React to retrieve elements for seamless page transitions with react-scroll

I've been working on creating a single-page website with a customized navbar using React instead of native JavaScript, similar to the example I found in this reference. My current setup includes a NavBar.tsx and App.tsx. The NavBar.tsx file consists o ...

React Component fails to load in Django frontend application

I have been following a Django-React tutorial from Tranversy Media on YouTube. The server is running fine, but the components in my App.js file are not showing up in the index.html. Can anyone please help me figure out what might be causing this issue? He ...

Turning off strict mode in the bundling process of React with webpack can be achieved by following

I'm facing an issue with my application. It works perfectly in all browsers except for IE, where it throws the following error: 0x800a0416 - JavaScript runtime error: Multiple definitions of a property not allowed in strict mode In my webpack.config ...