Modifying Checkbox BorderWidth in Material UI v5

Seeking assistance with adjusting the checkbox border width in Material UI v5. I currently have a custom checkbox and would like to remove the border width. Despite trying numerous solutions, I have been unsuccessful so far.

checkbox

 <Checkbox
     defaultChecked
     size="small"
     checkedIcon={<span className={clsx(classes.icon, classes.checkedIcon)} />}
     icon={<span className={classes.icon} />}
 />

styles

 icon: {
      borderRadius: 6,
      width: 24,
      height: 24,
      borderWidth: 25,
      boxShadow: 'inset 0 0 0 1px rgba(16,22,26,.2), inset 0 -1px 0 rgba(16,22,26,.1)',
      backgroundColor: '#f5f8fa',
    },
    checkedIcon: {
      borderWidth: 20,
      backgroundColor: theme.palette.secondary.main,
      backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,0))',
      '&:before': {
        display: 'block',
        width: 24,
        height: 24,
        backgroundImage:
          "url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath" +
          " fill-rule='evenodd' clip-rule='evenodd' d='M12 5c-.28 0-.53.11-.71.29L7 9.59l-2.29-2.3a1.003 " +
          "1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l5-5A1.003 1.003 0 0012 5z' fill='%23fff'/%3E%3C/svg%3E\")",
        content: '""',
      },
      'input:hover ~ &': {
        backgroundColor: theme.palette.secondary.dark,
        borderWidth: 20,
      },
},

Answer №1

Utilizing an icon with a material checkbox allows you to designate different icons for when the checkbox is checked and unchecked. Take a look at this example:

<Checkbox icon={<FavoriteBorder />} checkedIcon={<Favorite />} name="checkedH" />

Answer №2

To decrease the borderWidth in your checkbox styles, simply include stroke and strokeWidth:

 stroke: "#ffffff",  stroke-width: 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

Transitioning images smoothly and responsively with jQuery, creating a beautiful

Hey there! I'm looking for some help with transforming this jQuery effect. Instead of having fixed sized images, I want to set the size in percentage (width:100%; height:auto) so they can be responsive. Any creative ideas or suggestions? <scri ...

Exploring Shopify's Graphql capabilities - Retrieving metafields for all products

I am currently in the process of developing a unique storefront using nextJS and shopify APIs. One key feature I am working on is a personalized catalog filtering system that utilizes metafields. My goal is to efficiently retrieve all products' metaf ...

Including a unicode escape sequence in a variable string value

I'm struggling to find the right way to include a unicode escape in a dynamic string value to display emojis in React. My database stores the hexcode for the emoji (1f44d) I have set up a styled-component with the necessary css for rendering an emoj ...

transfer properties to a dynamic sub element

I am currently working on a multi-step form project. I have successfully implemented the form so that each step displays the corresponding form dynamically. However, I am facing challenges in passing props to these components in order to preserve the state ...

The function getServerSideProps is not defined in the NextJS environment

I am facing an issue where I need to pass an array called initialPosts into my Home function using getServerSideProps, but the props are showing up as undefined. Despite trying various solutions, none of them seem to work. In getServerSideProps, I have us ...

Render images conditionally as background elements for the body, ensuring they do not increase the height of pages with minimal content

Incorporating NextJS image components into the RootLayout of a NextJS component with negative z-indexes and absolute positioning was necessary to align them with dynamic content. However, an issue arose when these images at the base route '/' cre ...

What is the best way to create a scrollable tbody in an HTML table using React?

In my current project, I am using React, Node, Express, and Postgres to fetch data from a database. The issue I'm facing involves creating a scrollable table within a div that spans the entire screen width. Initially, I had to apply display: block to ...

Place a small image within a list item to ensure it matches the height of the list element

I need help aligning images to the right within list elements. The images are squares with equal height and width, and I want them to fit snugly within the height of the list element on the right side. My HTML code is quite simple for now (see example bel ...

The alignment of images loop and videos loop is off

https://i.stack.imgur.com/6o38F.jpg I am facing an issue with a td container in which I am using PHP to loop through a collection of videos and images. Strangely, the videos are displaying higher than the images even though they are both contained within ...

Why do my padding and font size fail to match the height of my container?

When setting the height of my boxes to match the height of my <nav>, I encountered overflow issues. Despite using a 10rem height for the nav and a 2.25rem font, calculating the padding as 10-2.25/2 didn't result in the desired outcome. Can someo ...

Navigate to the parent element in the DOM

Looking to add some unique styling to just one of the many Mat dialog components in my project. It seems like modifying the parent element based on the child is trickier than expected, with attempts to access the DOM through the <mat-dialog-container> ...

Different ways to style this form using only CSS

Consider the HTML code below: <form> <p> <label for="id_name">Name:</label> <input id="id_name" maxlength="40" name="name" type="text"> </p> <p> <label for="id_format">Fo ...

`Why Mui Datepicker always shows the wrong date?`

Currently utilizing the Mui Datepicker library from @mui/x-date-pickers/DatePicker. Below is a snippet of my code <LocalizationProvider dateAdapter={AdapterDateFns}> <DatePicker inputFormat="MM/dd/yy" value={date} minDate= ...

Can you identify the attribute used for marking up an HTML code tag?

While examining a website's code to understand how they styled a specific section of their page, I came across the following snippet: <code markup="tt"> I thoroughly checked for any other references to this particular markup attribute ...

Excessive image display | HTML and CSS synergize

I am having some trouble with my image gallery. Each image is displayed as a vertical column and has zooming effects when hovered over. Clicking on an image should show it in full screen with a caption. The problem arises when dealing with images that are ...

Arrangement of code: Utilizing a Node server and React project with a common set of

Query I am managing: a simple react client, and a node server that functions as both the client pages provider and an API for the client. These projects are tightly integrated, separate TypeScript ventures encompassed by a unified git repository. The se ...

What is the reason behind the delayed mutation of the state when invoking the setState method in React?

Currently diving into the Forms section within the documentation of ReactJS. Just implemented this code snippet to showcase the use of onChange (JSBIN). var React= require('react'); var ControlledForm= React.createClass({ getInitialState: f ...

Directory structure for creating web applications using the React CLI

I have developed a react application using the react CLI. During development, it runs from the root of the web server: http://localhost:3000 by utilizing npm start: "start": "react-scripts start" However, when deploying the app, I need to place it ...

The custom Node server triggers a loading failure in Nextjs with the error message 'No `pages` directory was located'

As I embark on bootstrapping a fresh Next.js application, one of the requirements for integrating with Auth0 is to have my localhost running on HTTPS. Following the instructions provided in this article (https://medium.com/responsetap-engineering/nextjs-ht ...

Learn how to efficiently reload a card in React upon submitting new data

Is there a way to automatically refresh the card component after submitting data without having to manually refresh the page? I've tried using useEffect but it's not updating the data even though the value is changing. Any suggestions on how to r ...