我不知道如何从react select中移除边框或轮廓(不确定是哪一个).

上传图片供参考.我默认没有边界.enter image description here

customStyle = {      
        control: provided => ({
            ...provided,           
            height: 10,
            width: 300,
            padding: 10,
            margin: 0,
            marginLeft: 0,
            border: "0px solid black",
            fontSize: 13,
            backgroundColor: 'white',
            outline: 'none'            
        })
    }  

谢谢

推荐答案

react Select v3

const style = {
  control: base => ({
    ...base,
    border: 0,
    // This line disable the blue border
    boxShadow: 'none'
  })
};

这是live example美元

react Select v2

要在Select聚焦时重置边界,有两种解决方案:

  1. 使用state

    control: (base, state) => ({
        ...base,
        border: state.isFocused ? 0 : 0,
        // This line disable the blue border
        boxShadow: state.isFocused ? 0 : 0,
        '&:hover': {
           border: state.isFocused ? 0 : 0
        }
    })
    
  2. 使用!important(这一款有效,但我建议使用第一款

    control: base => ({
       ...base,
       border: '0 !important',
       // This line disable the blue border
       boxShadow: '0 !important',
       '&:hover': {
           border: '0 !important'
        }
    })
    

别忘了重置你得到的boxShadow(蓝色边框).

这是live example美元.

Reactjs相关问答推荐

滚动事件监听器在Next.js客户端组件中不触发

如何在没有 node 模块的情况下利用外部Java脚本文件制作OWL carousel

是否将样式应用于父悬停(框架运动)上的子元素?

取消 Select 较高组件中的所有行

如何更新 FunctionComponentElement 的 props

如何更新redux状态存在的输入框

如何在next.js 13中仅在主页导航栏上隐藏组件?

BrowserRouter改变了URL但没有链接到页面

FlatList 不在 React Native 中呈现项目

为嵌套路由配置一个不存在的 url 的重定向

无法在 KeyDown 上调用 useCallback 函数

使用 Vite 的 React 中的路由无法正常工作(构建中)

我如何在所有组件中使用 Chakra UI toast?

如何从其他组件访问 useQuery refetch 方法?

react-query、react-hook-form 和表单验证

如何使用 useEffect 和 if 语句 React

理解 React 中的 PrevState

如何在 v6.4 中将 Auth0 提供程序与新的 createBrowsereRouter 一起使用?

如何在 Reactjs 中判断受保护路由上的用户角色?

错误(未捕获的类型错误):无法读取未定义的属性(读取参数)