材质UI选项卡如何更改方向

时间:2020-02-22 06:18:07

标签: reactjs material-ui

到目前为止,我尝试使用带有断点选择器的自定义CSS,但是我想使其更加素材,为什么没有自定义样式和状态?有例子吗?

有没有更好的方法建议

 <Tabs
   value={this.state.tab.value}
   orientation={"horizontal"} <-- to change vertical or horizontal depends on

1 个答案:

答案 0 :(得分:0)

试试这个

import withWidth, { isWidthUp } from "@material-ui/core/withWidth";
    
    let condTabOrientation;
      if (isWidthUp("sm", props.width)) {
        condTabOrientation = "vertical";
      } else {
        condTabOrientation = "horizontal";
      }
    
    
    <Tabs
    orientation={condTabOrientation}     
     />
    
    export default withWidth() (UserAccount);

查看更多断点文档

https://material-ui.com/customization/breakpoints/#withwidth-options-higher-order-component