I find myself grappling with the styling issue in MUI select

<FormControl>
<Select
      labelId="unique-label"
        id="unique-id"
        value={1}
        className={styles.uniqueCustomSelectRoot}
        IconComponent={() => <MyUniqueIcon />}
        sx={{
          ".MuiOutlinedInput-notchedOutline": { border: 0},
          paddingLeft: "10px",
          paddingRight: "10px",
        }}
      >
        <MenuItem value={1}>Option 1</MenuItem>
        <MenuItem value={2}>Option 2</MenuItem>
        <MenuItem value={3}>Option 3</MenuItem>
      </Select>
</FormControl>

Looking for a way to adjust the default paddingRight in the Select component of a MUI button? It's currently set at 32px and I can't seem to change it.

I've attempted the following CSS code: "+ .MuiSelect-root .MuiSelect-select:focus": { padding: 0, }, but no changes were observed. Any suggestions?

Answer №1

You can find it by looking for the SelectDisplayProps section in your code

<FormControl>
    <Select
      // other props
      SelectDisplayProps={{
        style: { 
          paddingLeft: "10px",
          paddingRight: "10px" 
        },
      }}
    >
      Your content goes here
    </Select>
  </FormControl>

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

Discover the secret to extracting a unique style from inspect mode and incorporating it into your CSS design

I'm currently working on my angular project and I've imported the ngx-editor. My goal is to reduce the height of the editor, but I'm facing some challenges. After inspecting the element, I was able to adjust the height successfully within th ...

Error: NULL value detected when attempting to access property 'contains'

Currently, I am following a tutorial on implementing search with Algolia using Gatsby. Being new to Gatsby, I am encountering an issue with the code below. I have included the remaining code from the search/index.js file... import React, { useState, useE ...

Clicking elements reveal but page height remains unchanged?

Clicking on a label within #row-product_id_page-0-0 triggers the display of #row- elements as shown in the code snippet below: $('#row-product_id_page-0-0 label').click(function() { var str = $(this).find('.am-product-title').text ...

Differences in line spacing can be observed between the INPUT and LABEL elements

What could be causing this unusual behavior when setting line-height to match font-size: While the height of label is 16px, the height of input is 18px... Why is that? If I adjust line-height: 18px or higher, the heights suddenly align. But why does this ...

Communication via socket between an external server, our server, and a client built using React

Currently, I am operating a server using express. Within this server, I have established a connection with an external socket server which uses "wss://..." as the protocol. While I am able to receive data from this external websocket, my primary inquiry ...

Is it possible to adjust the ul width to match its parent's width using CSS?

Whenever I type in a search, a list is displayed. The issue arises on small devices where the width of the list exceeds that of the search input or its parent container, which should not happen. On small devices, it should always look like this: Example L ...

Starting the animation only when the slide is visible

Struggling to add animations dynamically as a HTML/CSS developer who avoids JS but uses jQuery occasionally? Sound familiar? Well, I have. Recently, I managed to create a CSS-3 animation for the images in a Bootstrap carousel. Check out the code below: ...

Maintain the grouping of elements within a div when printing in Internet Explorer 8

When printing in IE8, I'm facing an issue with keeping the "Table title" line on the same page as the <table>. Despite using page-break-inside:avoid;, there is still a page break between the table title and the actual table. My expectation is f ...

What is the best way to select and style individual HTML elements using CSS?

Having trouble editing a Validations Form in Ionic 4 with CSS. It seems that only the form elements are targeted after clicking on the form group. Attached below are the form states before and after click. I'm unable to style the form elements before ...

"Elevate your dashboard design with Syncfusion's dynamic layout options

I recently attempted to incorporate a DashboardLayoutComponent from syncfusion into a basic react App. The setup was simple, just wrapping the DashboardLayoutComponent around the app. However, I encountered an issue where the height of the DashboardLayout ...

Is there a method to adjust the order in which components are rendered?

Is there a way to render ComponentOne after ComponentTwo without changing their positions, even though ComponentOne requires several seconds for computation? function HOME(){ //some code return( <> < ComponentOne /> ...

Ensuring the correct width for a .png image in an email newsletter for Outlook 2013

After creating an email newsletter that works perfectly on all email clients except Outlook 2013, I realized that the image I included is not adhering to the table width specified. Instead, it is defaulting to its own width of 658px. View image here Below ...

Ways to adjust the anchor and h1 elements using CSS

I'm working on an HTML document with some markup, <a class="home-link" href="index.html" rel="home"> <h1 class="site-title">John Arellano's Personal Website</h1> </a> While styling the site title, I encountered a problem ...

What are the steps to utilizing an npm package that simply encapsulates my JavaScript code?

Our current npm package is designed for clients working on ES6-based projects, such as React. The main index file of the package looks like this: export function ourFunction() { } Clients import this function using the following syntax: import { ourFunc ...

Testing the existence of a specific icon with Jest and material-ui

Recently, I upgraded my application to mui v4 and I am really enjoying it. I also made adjustments to our test suite which now runs with jest/enzyme. For instance, I have started using mount instead of shallow. However, one issue I'm facing is the c ...

Display the background-image of the <body> element only when the image has finished loading

I have a webpage where I want to delay showing a large image until it has finished downloading. Instead, I would like to display a background with a fading effect while the image loads. The challenge is that the background image must be set within the bod ...

Ways to keep the position of an expanded collapsible table from Material UI intact

I found a collapsible table code snippet on this website: https://mui.com/material-ui/react-table/#collapsible-table However, there seems to be an issue where when I expand a row, the table "grows up" as it increases in size. This behavior is not ideal. I ...

Give the Row ID as a parameter to a personalized component within MUI Datagrid Pro

I am currently exploring the idea of incorporating an intermediate state to row checkboxes based on the selection status of other checkboxes within a detailed panel. My approach involves crafting a custom checkbox component and implementing some logical ...

Include additional content in the mui datepicker widget

Is there a way to include additional text in the mui datepicker? https://i.stack.imgur.com/wj84R.png import React, { useState } from "react"; import { DateTimePicker, KeyboardDateTimePicker } from "@material-ui/pickers"; function Inlin ...

The 'keepMounted' attribute in Material UI Select component is failing to display menu items on the DOM

My main goal is to ensure that my menu items are properly mounted in the DOM for SEO purposes. To achieve this, I am utilizing a MUI Select component for a dropdown navigation and passing in the necessary props like keepMounted, which are then spread on th ...