[英]Material UI - Tab icon Styles
我正在動態使用此選項卡:
<Tabs
value={value}
onChange={handleChange}
variant="scrollable"
scrollButtons="off"
indicatorColor="primary"
textColor="primary"
aria-label="scrollable"
classes={{
indicator: classes.indicator,
flexContainer: classes.flexContainer,
}}
>
{routes.map((value, index) => (
<Tab
classes={{
root: classes.tabRoot,
wrapper: classes.wrapper,
labelIcon: classes.labelIcon,
selected: classes.selected,
}}
key={index}
label={strings(value)}
icon={getIcon(value)}
{...a11yProps(index)}
/>
))}
{<Grid container>
<Grid item xs>
<PrintButton
type= "widget"
params={queryParams}
style={{
textTransform: "capitalize",
float: "right"
}}
/>
</Grid>
</Grid>}
</Tabs>
這是 getIcon 函數:
const getIcon = (value) => {
if (value === eventType.view) return <PageviewIcon />;
if (value === eventType.lead) return <ContactsIcon />;
if (value === eventType.share) return <ShareIcon />;
if (value === eventType.follow) return <GroupAddIcon />;
if (value === eventType.media) return <PermMediaIcon />;
if (value === eventType.print) return <FindInPageIcon />;
return null;
};
但我無法找到一種方法來替換這個類MuiTab-labelIcon .MuiTab-wrapper默認情況下是這樣的:
在更新到 Material UI v4 之前我沒有遇到這個問題
<ShareIcon style={{paddingBottom: '0px', paddingRight: "10px"}}/>
我將不勝感激任何幫助,提前致謝!!
用父組件包裹 Text 和 Icon 並應用
style={{ display: 'flex', alignItems: 'center', flexDirection: 'row', justifyContent: 'center' }}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.