How to style react-select options

前端 未结 6 1513
甜味超标
甜味超标 2020-12-24 02:20

What\'s the best way to style a react-select component\'s (https://github.com/JedWatson/react-select) options?

I can target the select itself just fine,

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-24 03:14

    This is how you override the theme styles:

    import React from "react";
    import Select from "react-select";
    
    class SelectComponent extends React.Component {
      componentDidMount() {}
      render() {
        const { data } = this.props;
    
        const options = [
          { value: "21", label: "21%" },
          { value: "9", label: "9%" },
          { value: "0", label: "0%" }
        ];
    
        const theme = theme => ({
          ...theme,
          colors: {
            ...theme.colors,
            primary25: "#f3f3f3",
            primary: "pink"
    
            // All possible overrides
            // primary: '#2684FF',
            // primary75: '#4C9AFF',
            // primary50: '#B2D4FF',
            // primary25: '#DEEBFF',
    
            // danger: '#DE350B',
            // dangerLight: '#FFBDAD',
    
            // neutral0: 'hsl(0, 0%, 100%)',
            // neutral5: 'hsl(0, 0%, 95%)',
            // neutral10: 'hsl(0, 0%, 90%)',
            // neutral20: 'hsl(0, 0%, 80%)',
            // neutral30: 'hsl(0, 0%, 70%)',
            // neutral40: 'hsl(0, 0%, 60%)',
            // neutral50: 'hsl(0, 0%, 50%)',
            // neutral60: 'hsl(0, 0%, 40%)',
            // neutral70: 'hsl(0, 0%, 30%)',
            // neutral80: 'hsl(0, 0%, 20%)',
            // neutral90: 'hsl(0, 0%, 10%)',
          }
          // Other options you can use
          // borderRadius: 4
          // baseUnit: 4,
          // controlHeight: 38
          // menuGutter: baseUnit * 2
        });
    
        return (
          
                            
        
    提交评论

提交回复
热议问题