How to change the style of a Ant-Design 'Select' component?

后端 未结 7 1708
栀梦
栀梦 2021-01-02 07:57

Suppose I want to change the standard white background color of the Select component to green.

My try...


        {children}
      
  ,
  mountNode,
);
/* TestPage.less */
.customSelect {
  :global {
    .ant-select-selection {
      max-height: 51px;
      overflow: auto;
    }
  }
}

Two points need to be noted:

The imported antd component class name is not translated by CSS Modules, so the overridden class name .ant-select-selection must be put in :global. Because of the previous note, the override is global. To avoid affecting other Select components, the setting needs to be wrapped by an extra classname to add range restriction

提交回复
热议问题