question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Select doesn't support variant="outlined"

See original GitHub issue

So in the docs of Select component we can choose from either standard, outlined or filled variants

<Select variant='outlined' />

However by default adding outlined doesn’t change a thing on the component visuall, except that it receives outlined class.

There is this another issue https://github.com/mui-org/material-ui/issues/13049 where this has been discussed but I think hasn’t been actually addressed properly.

In the previous issue it’s claimed that the implementation is correct and only documentation needs fixing. Documentation indeed was updated but in the example author uses OutlinedInput which is manually passed to Select. IMO this is incorrect because as a user I expect that variant="outlined" would just work without me needing to do that manual labor of passing Input manually.

This is how at least TextField component works, you just pass variant and it works.

Expected Behavior 🤔

<Select variant='outlined' />

Should render something like this: image

Current Behavior 😯

No outlined is rendered by default: image

Steps to Reproduce 🕹

Link:

https://codesandbox.io/s/jl7nm4no0y

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:18
  • Comments:41 (33 by maintainers)

github_iconTop GitHub Comments

16reactions
oliviertassinaricommented, Apr 29, 2019

I would probably do:

      <TextField
        select
        variant="outlined"
        value={values.age}
        onChange={handleChange}
        inputProps={{ name: "age", id: "outlined-age-simple" }}
      >
        <MenuItem value="">
          <em>None</em>
        </MenuItem>
        <MenuItem value={10}>Ten</MenuItem>
        <MenuItem value={20}>Twenty</MenuItem>
        <MenuItem value={30}>Thirty</MenuItem>
      </TextField>

https://codesandbox.io/s/yqy753v80j

Capture d’écran 2019-04-29 à 15 25 13

anytime I need to use the outlined variant.

@t49tran Let me see if we can improve the situation. Hold on.

15reactions
OutlinedInputcommented, Apr 13, 2019

What’s worse, is that the documentation for producing an actual outlined select requires the use of ‘ref’ to control ‘labelWidth’ on OutlinedInput. MUI’s Typescript definitions don’t support the ref property at all. Ideally, ‘variant’ would work like TextField or be removed all together.

https://material-ui.com/demos/selects/

  <FormControl variant="outlined" className={classes.formControl}>
          <InputLabel
            **ref={ref => {
              this.InputLabelRef = ref;
            }}**
            htmlFor="outlined-age-simple"
          >
            Age
          </InputLabel>
          <Select
            value={this.state.age}
            onChange={this.handleChange}
            input={
              <OutlinedInput
                **labelWidth={this.state.labelWidth}**
                name="age"
                id="outlined-age-simple"
              />
            }
          >
            <MenuItem value="">
              <em>None</em>
            </MenuItem>
            <MenuItem value={10}>Ten</MenuItem>
            <MenuItem value={20}>Twenty</MenuItem>
            <MenuItem value={30}>Thirty</MenuItem>
          </Select>
        </FormControl>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Select doesn't support variant="outlined" · Issue #14203 - GitHub
I've encountered the same issue with Select component. As the document suggests, I expect the declare variant = filled | outlined is enough...
Read more >
'outlined' not working in Material UI Select - Stack Overflow
The problem with below code is that variant="outlined" is not getting applied. I am not able to see the outline/border which should be...
Read more >
Select API - Material UI - MUI
Name Type Default autoWidth bool false children node classes object
Read more >
Input Components - React-admin - Marmelab
MUI offers 3 variants for text fields: outlined , filled , and standard . The default react-admin theme uses the filled variant. Most...
Read more >
Select layers and objects – Figma Help Center
This will allow you to select as many objects as you like. ... Viewing outlines in Figma design is like putting an x-ray...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found