代码之家  ›  专栏  ›  技术社区  ›  SoftTimur

删除TextField的下边框

  •  0
  • SoftTimur  · 技术社区  · 2 年前

    我想删除Fluent UI的TextField的底部边框。我尝试了以下代码,但没有成功。

    import "./styles.css";
    import { TextField } from "@fluentui/react";
    
    export default function App() {
      return (
        <TextField
          style={{
            textarea: { border: "none", borderBottom: "none" },
            input: { border: "none", borderBottom: "none" }
          }}
        />
      );
    }
    

    有人能帮忙吗?

    PS:代码沙盒: https://codesandbox.io/s/epic-ramanujan-0jcsw1?file=/src/App.js:0-280

    1 回复  |  直到 2 年前
        1
  •  2
  •   alex3683    2 年前

    边界定义在 fieldGroup TextField的元素。因此,使用 ITextFieldStyles 接口:

    import "./styles.css";
    import { TextField } from "@fluentui/react";
    
    export default function App() {
      return (
        <TextField
          styles={{
            fieldGroup: { borderBottom: "none" }
          }}
        />
      );
    }
    

    调整后的沙盒: https://codesandbox.io/s/romantic-chandrasekhar-rp3x8f?file=/src/App.js:0-210

        2
  •  0
  •   Briant    2 年前

    尝试在.css上使用此代码

    .no-border {
      border-bottom: none;
      outline: none;
    }
    

    这个在你的代码上

    import "./styles.css";
    import { TextField } from "@fluentui/react";
    
    export default function App() {
      return <TextField className="no-border" />;
    }