Altering the dimensions of radio buttons

I am a newcomer to using material-ui. I am currently working on incorporating radio buttons in a component and would like to reduce its size. While inspecting it in Chrome, I was able to adjust the width of the svg icon (1em). However, I am unsure how to achieve this through css or jsx (using the classes prop).

This is the structure of the generated markup that needs resizing for the icon with the class "MuiSvgIcon-root-41":

<label class="MuiFormControlLabel-root-151 ContractOfferPaymentMethodSelector-label-148">
  <span class="MuiButtonBase-root-54 MuiIconButton-root-48 MuiSwitchBase-root-160 MuiRadio-root-155 MuiRadio-colorSecondary-159 MuiSwitchBase-checked-161 MuiRadio-checked-156">
    <span class="MuiIconButton-label-53">
      <svg class="MuiSvgIcon-root-41" focusable="false" viewBox="0 0 24 24" aria-hidden="true">
        <path d="M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path>
      </svg><input class="MuiSwitchBase-input-163" name="paymentMethod" type="radio" value="Stripe">
    </span>
    <span class="MuiTouchRipple-root-57"></span>
  </span>
  <span class="MuiTypography-root-164 MuiTypography-body1-173 MuiFormControlLabel-label-154">Credit Card (standard)</span>
</label>

------- UPDATE ------

Here is the React component implemented in TypeScript:

import React, { ChangeEvent } from 'react'
import {
  WithStyles,
  Theme,
  withStyles,
  RadioGroup,
  Radio,
  FormControlLabel,
  Card,
  CardContent,
} from '@material-ui/core'
import { t } from 'translate'

interface IOwnProps {
  active: boolean
  paymentMethod: string
  handleChange: (paymentMethod: string) => void
}

type TProps = WithStyles<typeof styles> & IOwnProps

const styles = (theme: Theme) => ({
  card: {
    padding: 0,
    borderLeft: `8px solid ${theme.palette.secondary[500]}`,
  },
  label: {
    display: 'flex',
    flexBasis: '100%',
  },
})

const ContractOfferPaymentMethodSelector: React.SFC<TProps> = (props: TProps) => {
  const { classes, paymentMethod, handleChange } = props

  return (
    <div className="ContractOfferPaymentMethodSelector">
      <header className="ContractOfferPaymentMethodSelector__header">
        <div className="ContractOfferPaymentMethodSelector__header-title">{t('Payment method')}</div>
      </header>
      <Card className={`ContractOfferPaymentMethodSelector__main ${classes.card}`}>
        <CardContent>
          <RadioGroup
            className="ContractOfferPaymentMethodSelector__group"
            aria-label="Payment Method"
            name="paymentMethod"
            value={paymentMethod}
            // tslint:disable-next-line:jsx-no-lambda
            onChange={(e: ChangeEvent<{}>, value: string) => {
              handleChange(value)
            }}
          >
            <FormControlLabel
              className={classes.label}
              value="Stripe"
              control={<Radio />}
              label={t('Credit card (standard)')}
            />
            <FormControlLabel className={classes.label} value="B2B" control={<Radio />} label={t('EDI charge')} />
          </RadioGroup>
        </CardContent>
      </Card>
    </div>
  )
}

export default withStyles(styles)(ContractOfferPaymentMethodSelector)

Answer №1

To improve your css, experiment with:

.label svg {
    size: 1em;
}

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

What is the best way to align a button to the right in Material-UI?

I've been experimenting with Material UI, but I'm having trouble aligning buttons to the right :( import * as React from "react"; import SvgIcon from "@mui/material/SvgIcon"; import Button from "@mui/material/Button" ...

What is the best method for transforming an object into an interface without prior knowledge of the keys

I am looking for a solution to convert a JSON into a TypeScript object. Here is an example of the JSON data: { "key1": { "a": "b" }, "key2": { "a": "c" } } The keys key1 and key2 a ...

Completely place one element with respect to its sibling element

I am currently facing a situation where I have implemented a Navigation bar wrapper that reveals an overlay across the entire page when clicked. In order for this setup to function correctly, all the elements that the overlay covers must be sibling elemen ...

The minimum and maximum values specified in the InputProps are not being upheld

I am struggling with enforcing min/max character limits on my form. Here is the code I have: const handleSubmit = (event) => { //Make a network call somewhere event.preventDefault(); console.log("submitted"); } <form onSubmit={ha ...

Retrieving user input in React by utilizing the onChange event handler

I have been tasked with creating a Quiz App and I am currently working on building it. The app consists of several components such as "question", "question-list", and "add-question". Within the "add-question" component, there is a form that allows users ...

Setting up Material UI Icons in your React js project

I've been having trouble installing the Material UI Icons package with these commands: npm install @material-ui/icons npm install @material-ui/icons --force npm i @mui/icons-material @mui/material Error messages keep popping up and I can't see ...

Ensure that all items are centered while positioning one in the corner

Lately, I've been diving into the world of flexbox and trying out new things. However, there are still some concepts that elude me. My current project involves creating a straightforward layout with three flex items (children). The container is confi ...

What is the proper way to manage the (ion select) OK Button?

Hey there, I'm working with an Ionic select directive and I need to customize the functionality of the 'OK' button. When I click on it, I want it to call a specific function. I'm aware of the (ionChange) event, but that only triggers w ...

Combining enum values to create a new data type

Exploring the implementation of type safety in a particular situation. Let’s consider the following: const enum Color { red = 'red', blue = 'blue', } const enum Shape { rectangle = 'rectangle', square = 'square ...

What is the procedure for modifying the state array?

I am currently working with a state in my component set up like this: constructor(props){ super(props) this.state={ editableComparatorIndexes: [] } } But I am facing challenges when it comes to updating the state, and I need to achieve som ...

The art of masonry is not effective

I'm having trouble getting the Masonry cascading grid layout library to work in my code. Stylesheet: .post { background: #FFF; padding: 10px; border-bottom: 3px solid #e6e6e6; width: 30.7%; margin: 10px; } Source code: <div ...

Is there a way for me to retrieve form information?

I have encountered a challenge with my React app. The login form data appears to be empty when I attempt to send it to the backend. // Login component class submitLoginForm = (event) => { event.preventDefault(); const target = event.target; ...

Encounter the message "This page is unavailable" upon refreshing the page when utilizing Next Js and React-admin

Situation I have successfully developed a project utilizing React-admin and NextJS. Issue Upon refreshing the page, I am consistently redirected to the 404 error page. This problem emerged after removing the hash from the URL (localhost:3000/#/). The appl ...

Encountering an issue with Typescript Vue class-based components in Laravel Mix: issue arises when attempting to set property 'render' on an undefined object

I have been using Laravel Mix to compile my Vue components, incorporating TypeScript and class-based components. Each class is exported from the component, and every component is required by the context in the main application script. However, during rende ...

The class "slick" in <col class="slick"> does not add any styling or effects

My interpretation of the col element is that it can be used to assign a class to all elements in a column of a table. However, I am experiencing difficulties with this approach. While I am able to apply the class to individual td elements, I am looking for ...

Unable to detect tsc after installing globally within Windows Sandbox

I followed the instructions provided here to install TypeScript globally. npm install -g typescript After installing both inside vscode and outside, I encountered an issue where tsc --version does not work and shows 'tsc is not recognized'. Int ...

Filtering JSON array data in Typescript can help streamline and optimize data

Recently diving into Angular, I am facing a challenge with filtering data from a JSON array. My goal is to display names of items whose id is less than 100. The code snippet below, however, is not producing the desired result. list : any; getOptionList(){ ...

Is there a way to implement multiple "read more" and "read less" buttons on a single page?

I am currently working on a rather large project and I am encountering some issues with the read more buttons. As someone who is fairly new to JavaScript, I am still grappling with the concepts. While I have managed to make the function work for the first ...

Problem with Metadata Changes in Next.js: Metadata Getting Reset After Rebuilding .next Directory

I've run into a problem while trying to customize metadata in my Next.js app. Even though I can successfully make changes to the metadata in my layout.tsx file, these modifications are not showing up in the console output. Additionally, whenever I del ...

Stylish border radius for Bootstrap progress bars

Here is a snippet of code that I am struggling with: .progress-bar{ border-top-right-radius: 40px !important; border-bottom-right-radius: 40px !important; -webkit-box-shadow: none !important; -moz-box-shadow: none !important; box-sha ...