className 在 react-select 中不起作用

huangapple go评论65阅读模式
英文:

The className in react-select doesent apply

问题

I just started using react-select and when I try to add my styles using scss they dont apply, I know that there is an option for styles where you set option styles as well as control but I want a cleaner way using scss

Here is what I want:

className 在 react-select 中不起作用

Here is what I get after applying className:

className 在 react-select 中不起作用

Is there a way to disable the preset styles so I can make my own or how can I modify it so it takes my real styles here is my css:

.shippingCountryDropdownElement {
  border: none;
  height: 42px;
  background-color: red;
  color: gray;
  outline: none;
  font-weight: 400;
  font-size: 14px;
  line-height: 21px;
  cursor: pointer;
  &:focus {
    box-shadow: none;
  }
}

And if not is there a better solution for a dropdown than this library, any help would be great. Thanks in advance className 在 react-select 中不起作用

英文:

I just started using react-select and when I try to add my styles using scss they dont apply, I know that there is option for styles where you set option styles as well as control but I want a cleaner way using scss

Here is what I want:

className 在 react-select 中不起作用

Here is what I get after applying className:

className 在 react-select 中不起作用

Is there a way to disable the preset styles so I can make my own or how can I modify it so it takes my real styles here is my css:

.shippingCountryDropdownElement {
  border: none;
  height: 42px;
  background-color: red;
  color: gray;
  outline: none;
  font-weight: 400;
  font-size: 14px;
  line-height: 21px;
  cursor: pointer;
  &:focus {
    box-shadow: none;
  }
}

And if not is there a better solution for a dropdown than this library, any help would be great. Thanks in advance className 在 react-select 中不起作用

答案1

得分: 1

对于 react-select 组件,您可以像这样修改其默认样式:

// 隐藏指示线
.shippingCountryDropdownElement .select__indicator-separator {
  display: none;
}

// 隐藏字段周围的边框
.shippingCountryDropdownElement .select__control {
  border: 0px;
}

您可以在这里获取更多详细信息。

英文:

For the react-select component, you will be able to modify it's default style like this:

// To Hide Indicator Line
.shippingCountryDropdownElement .select__indicator-separator {
  display: none;
}

// To Hide Border Around Field
.shippingCountryDropdownElement .select__control {
  border: 0px;
}

You can refer here for more details on this.

huangapple
  • 本文由 发表于 2023年4月7日 00:29:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75951754.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定