如何将自定义样式设置为语义ui组件,reactjs

问题描述 投票:0回答:1

这是我的登录页面模型,表单字段已获得模态的全宽。我想在每个输入字段周围设置10px的边距。

enter image description here

import React from "react";
import ReactDOM from "react-dom";
import { Button, Input, Modal } from "semantic-ui-react";
import "semantic-ui-css/semantic.min.css";

function App() {
  return (
    <Modal dimmer="blurring" open={true} size={"medium"}>
      <Modal.Header>Login</Modal.Header>
      <Input fluid placeholder="Username" icon="user" />

      <Input fluid placeholder="Password" icon="key" type="password" />
      <Modal.Actions>
        <Button
          positive
          icon="checkmark"
          labelPosition="right"
          content="Submit"
        />
      </Modal.Actions>
    </Modal>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
css reactjs semantic-ui
1个回答
0
投票

这是直截了当的。但是我找不到文档。我只是简单地将样式添加到组件中。有效。

import React from "react";
import ReactDOM from "react-dom";
import { Button, Input, Modal } from "semantic-ui-react";
import "semantic-ui-css/semantic.min.css";

const inlineStyle = {
    input : {
      margin: '10px',
    }
  };
function App() {
  return (
    <Modal dimmer="blurring" open={true} size={"medium"}>
      <Modal.Header>Login</Modal.Header>
      <Input fluid placeholder="Username" icon="user" style={inlineStyle.input}/>

      <Input fluid placeholder="Password" icon="key" type="password" style={inlineStyle.input}/>
      <Modal.Actions>
        <Button
          positive
          icon="checkmark"
          labelPosition="right"
          content="Submit"
        />
      </Modal.Actions>
    </Modal>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
© www.soinside.com 2019 - 2024. All rights reserved.