To change the color of a Select component's border and arrow icon in Material-UI, you can leverage the classes prop and override the default styles using CSS-in-JS or makeStyles (for functional components). Here's how you can achieve this:
If you're using functional components, you can use the makeStyles hook to define custom styles and apply them to the Select component.
import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import Select from '@material-ui/core/Select'; import InputBase from '@material-ui/core/InputBase'; const useStyles = makeStyles((theme) => ({ select: { '&:before': { borderColor: 'green !important', // Change border color here }, '&:after': { borderColor: 'green !important', // Change border color here }, '&:hover': { borderColor: 'green !important', // Change border color here }, }, icon: { fill: 'green !important', // Change arrow icon color here }, })); const CustomizedSelect = () => { const classes = useStyles(); return ( <Select className={classes.select} input={<InputBase classes={{ icon: classes.icon }} />} defaultValue="" > {/* Your Select options here */} </Select> ); }; export default CustomizedSelect; makeStyles Hook: This hook from Material-UI allows you to define custom styles. Each key within the styles object corresponds to a CSS class or element you want to target.select Class: This targets the Select component and modifies its border color for different states (before, after, hover).icon Class: This modifies the arrow icon inside the Select component.If you are using class components or prefer the withStyles HOC (Higher Order Component) approach, you can achieve the same effect:
import React from 'react'; import { withStyles } from '@material-ui/core/styles'; import Select from '@material-ui/core/Select'; import InputBase from '@material-ui/core/InputBase'; const styles = (theme) => ({ select: { '&:before': { borderColor: 'green !important', // Change border color here }, '&:after': { borderColor: 'green !important', // Change border color here }, '&:hover': { borderColor: 'green !important', // Change border color here }, }, icon: { fill: 'green !important', // Change arrow icon color here }, }); class CustomizedSelect extends React.Component { render() { const { classes } = this.props; return ( <Select className={classes.select} input={<InputBase classes={{ icon: classes.icon }} />} defaultValue="" > {/* Your Select options here */} </Select> ); } } export default withStyles(styles)(CustomizedSelect); Select and InputBase from @material-ui/core as shown.!important to override default Material-UI styles.borderColor, fill) as per your design requirements.By following these examples, you can effectively customize the border color and arrow icon color of a Material-UI Select component using either the makeStyles hook for functional components or the withStyles HOC for class components. Adjust the colors and styles to fit your application's design.
Material UI Select component change border color
import React from 'react'; import { FormControl, Select, MenuItem } from '@material-ui/core'; import { withStyles } from '@material-ui/core/styles'; const CustomSelect = withStyles({ root: { '& .MuiOutlinedInput-root': { '&:hover fieldset': { borderColor: 'blue', // Change hover border color }, '&.Mui-focused fieldset': { borderColor: 'green', // Change focused border color }, }, }, })(Select); // Usage example: const MyComponent = () => { return ( <FormControl variant="outlined"> <CustomSelect value={''}> <MenuItem value={''}>Option 1</MenuItem> <MenuItem value={''}>Option 2</MenuItem> </CustomSelect> </FormControl> ); }; export default MyComponent; Material UI Select component change arrow color
import React from 'react'; import { FormControl, Select, MenuItem } from '@material-ui/core'; import { withStyles } from '@material-ui/core/styles'; const CustomSelect = withStyles({ iconOutlined: { color: 'red', // Change arrow color }, })(Select); // Usage example: const MyComponent = () => { return ( <FormControl variant="outlined"> <CustomSelect value={''}> <MenuItem value={''}>Option 1</MenuItem> <MenuItem value={''}>Option 2</MenuItem> </CustomSelect> </FormControl> ); }; export default MyComponent; Material UI Select component customize styles
import React from 'react'; import { FormControl, Select, MenuItem } from '@material-ui/core'; import { withStyles } from '@material-ui/core/styles'; const CustomSelect = withStyles(theme => ({ root: { '& .MuiOutlinedInput-root': { '&:hover fieldset': { borderColor: 'blue', // Change hover border color }, '&.Mui-focused fieldset': { borderColor: 'green', // Change focused border color }, }, '& .MuiSelect-iconOutlined': { color: 'red', // Change arrow color }, }, }))(Select); // Usage example: const MyComponent = () => { return ( <FormControl variant="outlined"> <CustomSelect value={''}> <MenuItem value={''}>Option 1</MenuItem> <MenuItem value={''}>Option 2</MenuItem> </CustomSelect> </FormControl> ); }; export default MyComponent; Material UI Select component override default styles
import React from 'react'; import { FormControl, Select, MenuItem } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; const useStyles = makeStyles(theme => ({ select: { '& .MuiOutlinedInput-root': { '&:hover fieldset': { borderColor: 'blue', // Change hover border color }, '&.Mui-focused fieldset': { borderColor: 'green', // Change focused border color }, }, '& .MuiSelect-iconOutlined': { color: 'red', // Change arrow color }, }, })); const MyComponent = () => { const classes = useStyles(); return ( <FormControl variant="outlined"> <Select className={classes.select} value={''} > <MenuItem value={''}>Option 1</MenuItem> <MenuItem value={''}>Option 2</MenuItem> </Select> </FormControl> ); }; export default MyComponent; Material UI Select component change outline color
import React from 'react'; import { FormControl, Select, MenuItem } from '@material-ui/core'; import { withStyles } from '@material-ui/core/styles'; const CustomSelect = withStyles(theme => ({ outlined: { '&$focused $notchedOutline': { borderColor: 'blue', // Change focused outline color }, }, focused: {}, notchedOutline: {}, }))(Select); // Usage example: const MyComponent = () => { return ( <FormControl variant="outlined"> <CustomSelect value={''}> <MenuItem value={''}>Option 1</MenuItem> <MenuItem value={''}>Option 2</MenuItem> </CustomSelect> </FormControl> ); }; export default MyComponent; Material UI Select component customize border and icon
import React from 'react'; import { FormControl, Select, MenuItem } from '@material-ui/core'; import { withStyles } from '@material-ui/core/styles'; const CustomSelect = withStyles(theme => ({ select: { '& .MuiOutlinedInput-root': { '&:hover fieldset': { borderColor: 'blue', // Change hover border color }, '&.Mui-focused fieldset': { borderColor: 'green', // Change focused border color }, }, '& .MuiSelect-iconOutlined': { color: 'red', // Change arrow color }, }, }))(Select); // Usage example: const MyComponent = () => { return ( <FormControl variant="outlined"> <CustomSelect value={''}> <MenuItem value={''}>Option 1</MenuItem> <MenuItem value={''}>Option 2</MenuItem> </CustomSelect> </FormControl> ); }; export default MyComponent; Material UI Select component change arrow icon style
import React from 'react'; import { FormControl, Select, MenuItem } from '@material-ui/core'; import { withStyles } from '@material-ui/core/styles'; const CustomSelect = withStyles(theme => ({ iconOutlined: { color: 'red', // Change arrow color transform: 'rotate(90deg)', // Example of changing arrow icon style }, }))(Select); // Usage example: const MyComponent = () => { return ( <FormControl variant="outlined"> <CustomSelect value={''}> <MenuItem value={''}>Option 1</MenuItem> <MenuItem value={''}>Option 2</MenuItem> </CustomSelect> </FormControl> ); }; export default MyComponent; Material UI Select component custom border style
import React from 'react'; import { FormControl, Select, MenuItem } from '@material-ui/core'; import { withStyles } from '@material-ui/core/styles'; const CustomSelect = withStyles(theme => ({ select: { '& .MuiOutlinedInput-root': { '&:hover fieldset': { borderColor: 'blue', // Change hover border color }, '&.Mui-focused fieldset': { borderColor: 'green', // Change focused border color }, borderWidth: '2px', // Example of changing border width borderRadius: '10px', // Example of adding border radius }, }, }))(Select); // Usage example: const MyComponent = () => { return ( <FormControl variant="outlined"> <CustomSelect value={''}> <MenuItem value={''}>Option 1</MenuItem> <MenuItem value={''}>Option 2</MenuItem> </CustomSelect> </FormControl> ); }; export default MyComponent; hashtable overriding restsharp textarea decoding xelement django-database tex radix asp.net-web-api2