首页 > 解决方案 > 如何将 Material UI TableSortLabel 箭头更改为左侧?

问题描述

我的表中有需要排序的右对齐和左对齐列。在列右对齐的情况下,我希望图标位于标题的左侧。否则会有一个尴尬的空间右对齐,因为图标只是隐藏,而不是不显示。

TabelSortLabel API 中没有任何东西允许这样做。

标签: cssreactjsmaterial-ui

解决方案


您可以使用 flex-direction: row-reverse,基于 alignContent 属性

flexDirection: ({ header }: Props) => {
      return header?.alignContent && header?.alignContent === 'right' ? 'row-reverse' : 'row';
    },

推荐阅读