You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决react-native-elements Button默认有圆角无法显示标准矩形的问题

解决方案

react-native-elements 的 Button 组件默认内置了圆角样式,直接在 buttonStyle 属性中添加 borderRadius: 0 即可覆盖默认样式,实现标准矩形效果。

修改后的代码如下:

<Button
      title="Next"
      onPress={() => {
        // Next 相关逻辑
      }}
      buttonStyle={{
          backgroundColor: "#000000",
          width: 'auto',
          borderRadius: 0 // 新增该属性覆盖默认圆角
      }}
/>

如果需要全局所有 Button 组件默认都是矩形样式,无需逐个配置,可以通过组件库的主题全局配置实现:

  • 首先在项目入口文件配置自定义主题:
import { ThemeProvider, createTheme } from '@rneui/themed';

const customTheme = createTheme({
  components: {
    Button: {
      buttonStyle: {
        borderRadius: 0
      }
    }
  }
});
  • 用自定义主题的 ThemeProvider 包裹你的应用根组件即可全局生效。

内容的提问来源于stack exchange,提问作者Nathan Getachew

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.23 18:36:01