简体   繁体   English

textAlign right 不适用于 material-ui 中的自定义垂直标签标签

[英]textAlign right not working for custom vertical tab label in material-ui

I am overriding the tabs of material-ui to have a vertical view of the tabs.我正在覆盖 material-ui 的选项卡以获得选项卡的垂直视图。 However, I also want the label (text) of these tabs to align to the right so it looks more uniform.但是,我也希望这些选项卡的标签(文本)向右对齐,使其看起来更统一。 I've tried every kind of styling but still cannot get it to work.我已经尝试了各种样式,但仍然无法让它发挥作用。

<VerticalTabs
      value={tabValue}
      indicatorColor={'primary'}
      onChange={this.handleTabChange}


    >
      <MyTab
        disableRipple
        lableStyle={{float: 'right'}} <----- doesn't work
        label="Sourcing"
      />
        <MyTab
        disableRipple
        lableStyle={{float: 'right'}}
        label="Production"
      />
      <MyTab
        disableRipple
        lableStyle={{float: 'right'}}
        label="Shipping"
      />
      <MyTab
        disableRipple
        lableStyle={{float: 'right'}}
        label="Sales"
      />
    </VerticalTabs>

override styling:覆盖样式:

const VerticalTabs = withStyles(theme => ({
  flexContainer: {
    flexDirection: 'column',
  },
  indicator: {
    display: 'none',
  },
  tabsRoot: {
    textAlign: 'right'
  }

}))(Tabs)

const MyTab = withStyles(theme => ({

  root: {
  borderRight: '2px solid lightgray',
  textAlign: 'right'


  },
  selected: {
    color: '#4ABDAC',
    borderRight: '3px solid #4ABDAC',
    textAlign: 'right'


  },
  label: {
    fontSize: 20,


    textTransform: 'initial',
  },


}))(Tab);

Can anyone point me in the right direction to align the label text to the right side of the tab container?谁能指出我正确的方向,将标签文本与选项卡容器的右侧对齐?

升级到最新版本的 material-ui 修复了这个问题(目前是 v3.9.1)

The Tab component in material ui has a wrapper with align-items: "center" css(MuiTab-wrapper) applied to it.材质 ui 中的 Tab 组件有一个包装器,其中应用了 align-items: "center" css(MuiTab-wrapper)。 You need to override this and change it to "flex-start" or "flex-end" https://material-ui.com/api/tab/您需要覆盖它并将其更改为“flex-start”或“flex-end” https://material-ui.com/api/tab/

wrapper: {
    alignItems: "flex-start"
}

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

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