3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

material-ui DataGridのpaginationラベルをローカライズしたい

Posted at

DataGridのテキストローカライズ

参考:DataGrid API

DataGrid用のローカライズpropはlocaleTextにオブジェクト入れればできるんですが、デフォルトのソースを見る限りではフッターのパジネーション部分のキーがありませんでした。

TablePaginationが利用されている

DataGrid内部ではmaterial-uiのcoreで提供されているTablePaginationを使っているみたいでした。

参考:GridPagination.tsx

なので、単純にcreateMuiThemeからデフォルトpropを変更すれば良さそうです。

labelDisplayedRows propの上書き

createMuiTheme > props > MuiTablePagination > labelDisplayedRowsにカスタマイズしたいように置くだけです。

参考:TablePagination API

const theme = createMuiTheme({
  props: {
    MuiTablePagination: {
      labelDisplayedRows: ({
        from,
        to,
        count,
      }: LabelDisplayedRowsArgs) => {
        return `${from}-${to} / ${count !== -1 ? count : `${to}以上`}`;
      },
    },
  },
});
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?