diff --git a/docs/pages/api/native-select.md b/docs/pages/api/native-select.md index 7c1d8494adafa4..b02477915e19ee 100644 --- a/docs/pages/api/native-select.md +++ b/docs/pages/api/native-select.md @@ -50,7 +50,9 @@ Any other props supplied will be provided to the root element ([Input](/api/inpu | outlined | MuiNativeSelect-outlined | Styles applied to the select component if `variant="outlined"`. | selectMenu | MuiNativeSelect-selectMenu | Styles applied to the select component `selectMenu` class. | disabled | Mui-disabled | Pseudo-class applied to the select component `disabled` class. -| icon | MuiNativeSelect-icon | Styles applied to the select component `icon` class. +| icon | MuiNativeSelect-icon | Styles applied to the icon component. +| iconFilled | MuiNativeSelect-iconFilled | Styles applied to the icon component if `variant="filled"`. +| iconOutlined | MuiNativeSelect-iconOutlined | Styles applied to the icon component if `variant="outlined"`. You can override the style of the component thanks to one of these customization points: diff --git a/docs/pages/api/select.md b/docs/pages/api/select.md index 28eb25b6962e47..10b9b4aabf4d41 100644 --- a/docs/pages/api/select.md +++ b/docs/pages/api/select.md @@ -60,7 +60,9 @@ Any other props supplied will be provided to the root element ([Input](/api/inpu | outlined | MuiSelect-outlined | Styles applied to the select component if `variant="outlined"`. | selectMenu | MuiSelect-selectMenu | Styles applied to the select component `selectMenu` class. | disabled | Mui-disabled | Pseudo-class applied to the select component `disabled` class. -| icon | MuiSelect-icon | Styles applied to the select component `icon` class. +| icon | MuiSelect-icon | Styles applied to the icon component. +| iconFilled | MuiSelect-iconFilled | Styles applied to the icon component if `variant="filled"`. +| iconOutlined | MuiSelect-iconOutlined | Styles applied to the icon component if `variant="outlined"`. You can override the style of the component thanks to one of these customization points: diff --git a/packages/material-ui/src/NativeSelect/NativeSelect.d.ts b/packages/material-ui/src/NativeSelect/NativeSelect.d.ts index 6ac2621de2ba00..65930036695dc8 100644 --- a/packages/material-ui/src/NativeSelect/NativeSelect.d.ts +++ b/packages/material-ui/src/NativeSelect/NativeSelect.d.ts @@ -15,11 +15,13 @@ export interface NativeSelectProps export type NativeSelectClassKey = | 'root' | 'select' + | 'filled' + | 'outlined' | 'selectMenu' | 'disabled' | 'icon' - | 'filled' - | 'outlined'; + | 'iconFilled' + | 'iconOutlined'; declare const NativeSelect: React.ComponentType; diff --git a/packages/material-ui/src/NativeSelect/NativeSelect.js b/packages/material-ui/src/NativeSelect/NativeSelect.js index 73575e74a10029..0186c05fcfab68 100644 --- a/packages/material-ui/src/NativeSelect/NativeSelect.js +++ b/packages/material-ui/src/NativeSelect/NativeSelect.js @@ -55,7 +55,7 @@ export const styles = theme => ({ }, /* Pseudo-class applied to the select component `disabled` class. */ disabled: {}, - /* Styles applied to the select component `icon` class. */ + /* Styles applied to the icon component. */ icon: { // We use a position absolute over a flexbox in order to forward the pointer events // to the input. @@ -65,6 +65,14 @@ export const styles = theme => ({ color: theme.palette.action.active, pointerEvents: 'none', // Don't block pointer events on the select under the icon. }, + /* Styles applied to the icon component if `variant="filled"`. */ + iconFilled: { + right: 7, + }, + /* Styles applied to the icon component if `variant="outlined"`. */ + iconOutlined: { + right: 7, + }, }); const defaultInput = ; diff --git a/packages/material-ui/src/NativeSelect/NativeSelectInput.js b/packages/material-ui/src/NativeSelect/NativeSelectInput.js index 3817a25454248a..ec699156824486 100644 --- a/packages/material-ui/src/NativeSelect/NativeSelectInput.js +++ b/packages/material-ui/src/NativeSelect/NativeSelectInput.js @@ -2,12 +2,21 @@ import React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; import { refType } from '@material-ui/utils'; +import { capitalize } from '../utils/helpers'; /** * @ignore - internal component. */ const NativeSelectInput = React.forwardRef(function NativeSelectInput(props, ref) { - const { classes, className, disabled, IconComponent, inputRef, variant, ...other } = props; + const { + classes, + className, + disabled, + IconComponent, + inputRef, + variant = 'standard', + ...other + } = props; return ( @@ -15,9 +24,8 @@ const NativeSelectInput = React.forwardRef(function NativeSelectInput(props, ref className={clsx( classes.root, // TODO v5: merge root and select classes.select, + classes[variant], { - [classes.filled]: variant === 'filled', - [classes.outlined]: variant === 'outlined', [classes.disabled]: disabled, }, className, @@ -26,7 +34,9 @@ const NativeSelectInput = React.forwardRef(function NativeSelectInput(props, ref ref={inputRef || ref} {...other} /> - {props.multiple ? null : } + {props.multiple ? null : ( + + )} ); }); diff --git a/packages/material-ui/src/Select/Select.d.ts b/packages/material-ui/src/Select/Select.d.ts index f255e4e0376c9a..819de3e6972cea 100644 --- a/packages/material-ui/src/Select/Select.d.ts +++ b/packages/material-ui/src/Select/Select.d.ts @@ -26,11 +26,13 @@ export interface SelectProps export type SelectClassKey = | 'root' | 'select' + | 'filled' + | 'outlined' | 'selectMenu' | 'disabled' | 'icon' - | 'filled' - | 'outlined'; + | 'iconFilled' + | 'iconOutlined'; declare const Select: React.ComponentType; diff --git a/packages/material-ui/src/Select/SelectInput.js b/packages/material-ui/src/Select/SelectInput.js index 2cb30d67d0a5e3..3edc7202333bce 100644 --- a/packages/material-ui/src/Select/SelectInput.js +++ b/packages/material-ui/src/Select/SelectInput.js @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; import warning from 'warning'; +import { capitalize } from '../utils/helpers'; import { refType } from '@material-ui/utils'; import Menu from '../Menu/Menu'; import { isFilled } from '../InputBase/utils'; @@ -49,7 +50,7 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) { tabIndex: tabIndexProp, type = 'hidden', value, - variant, + variant = 'standard', ...other } = props; @@ -261,10 +262,9 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) { classes.root, // TODO v5: merge root and select classes.select, classes.selectMenu, + classes[variant], { [classes.disabled]: disabled, - [classes.filled]: variant === 'filled', - [classes.outlined]: variant === 'outlined', }, className, )} @@ -299,7 +299,7 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) { autoFocus={autoFocus} {...other} /> - +