【发布时间】:2021-06-23 08:04:54
【问题描述】:
当前 MUI 按钮支持 size 属性值如下
smallmediumlarge
虽然这很方便,但我希望我可以将高度和宽度传递给 style 属性并自定义大小
<Button
variant="contained"
size="large"
onClick={onDownloadButtonClick}
style={{
width: '30em',
height: '40em' // call it humonguous
}}
>
Download
</Button>
知道如何实现这样的目标吗?
【问题讨论】:
-
你不能用
style={{width,height}}做那个吗? -
@NearHuscarl nope.
-
@AakashVerma this 方法有什么问题?
-
@NearHuscarl 哇,我从来没有注意到我可以在没有 px 的情况下传递值。让我试试。谢谢
-
@AakashVerma 默认情况下,
CssProperties中的数值使用px单位,因此20将转换为'20px'。只有在使用其他单位时才需要使用字符串(%,rem...)
标签: html css reactjs button material-ui