Select element from Material UI displaying horizontally

I'm brand new to Material Ui and currently tackling the implementation of their SELECT component. However, I am running into an issue where it is displaying in a row instead of a column. Am I overlooking something important here?

const SelectDropDownComponent = ({ options }) => {
  const classes = useStyles();
  const [age, setAge] = React.useState("");

  const handleChange = (event) => {
    setAge(event.target.value);
  };
  return (
    <div>
      <FormControl className={classes.formControl}>
        <Select
          value={age}
          onChange={handleChange}
          displayEmpty
          className={classes.selectEmpty}
          inputProps={{ "aria-label": "Without label" }}
        >
          <MenuItem value="">
            <em>None</em>
          </MenuItem>
          <MenuItem value={10}>Ten</MenuItem>
          <MenuItem value={20}>Twenty</MenuItem>
          <MenuItem value={30}>Thirty</MenuItem>
        </Select>
      </FormControl>
    </div>
  );
};

View Select when closed See Select when opened

Answer №1

Encountering a similar issue, I managed to work around it by specifying the style in the following manner:

<Select
        MenuProps={{
          MenuListProps: {
            sx: {
              "li.MuiButtonBase-root": {
                display: "flex",
                flexDirection: "column",
              },
            },
          },
        }}

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

The process of utilizing RxJS for server polling is a

My goal is to constantly update client-side data by polling the server. To achieve this, I have set up a dispatcher that triggers an action labeled FRONT_PAGE. This action is initiated when the app launches and the client is supposed to send requests every ...

Why won't my navigation bar stay in place when I scroll down on the screen?

I'm trying to create a sticky navigation bar that becomes fixed when the user scrolls down to 200 pixels, but it's not working properly. I want it to behave like in this example: import React,{useState,useEffect} from 'react' functio ...

The functionality of Flatbutton(Input handler) appears to be malfunctioning

I am having trouble with the file uploader from Material-UI. It doesn't seem to be working properly when I try to select a file. Does anyone have any suggestions on how to handle the input from the file selector? <FlatButton icon={< ...

Guide on modifying CSS properties when hovering over the parent element

I am working with a table structure like this: <table> <tr><td class="momdad"><i class='glyphicon glyphicon-cog'></i> Hello </td><td> Mom </td></tr> <tr><td class="momdad">< ...

Issue encountered when submitting form: Error identified as "Unexpected string expression without template curly in string"

As a novice in React.js, I am facing an issue where setState is not functioning properly when submitting a form. Any suggestions on how to resolve this problem? > class Home extends Component{ constructor(props){ > super(props) > ...

Differences between material-ui tables and HTML tables [ WARNING: Invalid element type]

What could be causing the error message: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. It's interesting that I encounter this error when using the material-u ...

Tips for centering the InputLabel in Material UI?

Upon loading the page, I am looking to have the InputLabel appear as shown in the second picture. However, I haven't been able to find any InputLabel props that achieve this. I attempted using the focused prop, but it didn't give me the desired o ...

Error: Please provide a JWT for authentication in Express.js - JsonWebTokenError

Description: I am in the process of developing a web application that utilizes Express.js for the backend and React for the frontend. My main focus is on implementing user authentication through the use of JSON Web Tokens (JWT). However, I have hit a roadb ...

Try utilizing an image to hold text content rather than a traditional div container

I am seeking help with displaying a brief image description at the bottom of an image. Currently, the display looks like this: https://www.bootply.com/render/Gwde8WHtot However, I would like the green background to align with the actual image rather than ...

Trouble Viewing Fonts on Mobile Devices like iPhones

I am experiencing a frustrating issue on my website. While using Agency FB and Calibri fonts, they appear correctly on all desktop browsers. However, when accessed from my iPhone, a different standard font is displayed instead. Both the logo and text with ...

Currently, I am developing a project in Next.js and looking to integrate the Cropper feature from the 'react-easy-crop' library. However, I am encountering some difficulties along the way

When creating a form input to select a file, the user can press import and a model will open with a cropper tool. After selecting the desired position and cropping the image, sometimes it displays as white or black depending on the selected picture. Result ...

I am experiencing difficulties updating my website

Is there a way to automatically refresh my webpage in PHP whenever I press the enter key? ...

How can I make a clickable button or link within an anchor tag that is still able to be right-clicked?

Hey there, I'm currently working on a notification dropdown menu where each <li> contains a link or an <a> tag. I'm aiming to create something similar to Facebook's notification system. However, the challenge lies in trying to ...

Encountering a HTTP 403 error when making POST requests to JIRA Cloud REST API using OAuth 2.0

I'm encountering a 403 error while attempting to connect my React app to the Jira Cloud API. My current code involves using OAuth 2.0 for authentication and successfully retrieves the token and cloudid. While I can use this information to GET issues, ...

Issues encountered with Nextjs and Jest when trying to utilize transformIgnorePatterns with esm modules

After extensive research, I have come across several solutions for my issue. However, I am struggling to make the transform and transformIgnorePatterns work as expected. At this point, my only workaround is manually adding mock modules inside the __mocks__ ...

Using TypeScript and Angular to modify CSS properties

I'm trying to figure out how to change the z-index CSS attribute of the <footer> element when the <select> is open in TypeScript (Angular 10). The current z-index value for the footer is set to 9998;, but I want it to be 0;. This adjustmen ...

Chrome glitch: how to make radio buttons bigger

Hey there! I'm having a little trouble trying to increase the size of my radio button using this CSS code. It seems to work in Mozilla, but not in Chrome. .rdo { margin: 1em 1em 1em 0; transform: scale(1.3, 1.3); -moz-transform: scale(1.3, 1.3); -ms- ...

Unable to navigate using react-router after logging out without a page refresh

In my logout approach, everything seems to work fine - there are no errors in the console, localHistory is cleared successfully, but for some reason it cannot navigate to the login page without refreshing the current page. const handleLogout = () => { ...

Encountering console errors with the new Date() constructor in Next.js

I've encountered an issue while attempting to utilize the new Date() constructor within a Next.js React component. Upon deployment, I'm getting the following console errors: Here is how I am using the date constructor: date: "2022-06-21T1 ...

Adjust the path of an element as it decreases in size

Sorry for the weird title, but that's likely why I can't find the solution on my own. I'm experimenting with CSS animations and I want the form element to decrease in height from 100px -> 0, but I want it to collapse from the top to the ...