简体   繁体   English

更改 Office UI Fabric React 组件的颜色

[英]Changing the color of Office UI Fabric React components

I am making an Office Fabric Panel in an React app, that is used as a form to create, update and delete an entity.我正在 React 应用程序中制作 Office Fabric 面板,用作创建、更新和删除实体的表单。 The thing is that on the delete-panel I want the primary button to be red instead of Fabric's standard blue.问题是在删除面板上,我希望主按钮为红色,而不是 Fabric 的标准蓝色。

If it is possible, I am sure it is very easy, but since I am inexperienced in HTML/CSS/JS, I don't know what to do and would like a solution that uses inline CSS.如果可能的话,我相信这很容易,但由于我对 HTML/CSS/JS 缺乏经验,我不知道该怎么做,想要一个使用内联 CSS 的解决方案。 I imagine that it will look something like this:我想它看起来像这样:

<PrimaryButton onClick={ this._onDelete } style={{marginRight: '8px', backgroundColor:'alert', color: 'white'}} >Delete</PrimaryButton>


MS's documentation doesn't help me a lot, I don't know what to import. MS 的文档对我帮助不大,我不知道要导入什么。 and my good friend Google hasn't done the trick this time.而我的好朋友谷歌这次没有成功。 I have found some answers that are close, but one is for overriding the theme of all components and another doesn't tell what to import (I guess that is the missing piece for me).我找到了一些接近的答案,但一个是覆盖所有组件的主题, 另一个没有告诉导入什么(我想这对我来说是缺失的部分)。

import { DefaultButton } from 'office-ui-fabric-react/lib/Button';

Then you can use the following:然后您可以使用以下内容:

<DefaultButton
    style={{backgroundColor:'black', color:'white'}}
    text='Accept'
/>

It's that easy :)就这么简单:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM