[英]How to not leave button in selected state after click - fluent-ui (office ui fabric)
Using DefaultButton
currently.当前使用DefaultButton
。 This remains selected when clicked, which property can be used to revoke selection once clicked.单击时保持选中状态,单击后可以使用哪个属性撤消选择。
Alternatively, is there any styling that needs to be done for selection?或者,是否需要进行任何样式选择?
You can use DefaultButton checked
property for that scenario and control it with onClick event:您可以为该场景使用DefaultButton checked
属性并使用onClick事件控制它:
const [isButtonChecked, setIsButtonChecked] = React.useState(false);
<DefaultButton
checked={isButtonChecked}
onClick={() => {
setIsButtonChecked(!isButtonChecked);
}}
styles={{
rootChecked: {
backgroundColor: '#f00',
color: '#fff',
}
}}
>
Default Button
</DefaultButton>
Use styles
property to modify button styles when button state is checked: rootChecked, rootCheckedHovered etc.选中按钮 state 时,使用styles
属性修改按钮 styles: rootChecked、rootCheckedHovered 等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.