how to change material table action fields icon

那年仲夏 提交于 2019-12-11 16:00:03

问题


        actions={[
          {
            icon: 'edit',
            tooltip: 'Edit User',
            onClick: (event, rowData) => alert('You are editing ' + rowData.name)
          },
          {
            icon: 'delete',
            tooltip: 'Delete User',
            onClick: (event, rowData) => confirm('You want to delete ' + rowData.name)
          }
        ]}

回答1:


You can change the icon of the action by supplying arbitrary React component as the value for icon prop.

icon string or () => ReactElement - Icon of button from material icons or custom component

So instead of edit or delete, add a component of a desired icon. Something like:

import { Edit } from '@material-ui/icons'

// ...

{
  icon: <Edit />,
  tooltip: 'Edit User',
  onClick: (event, rowData) => alert('You are editing ' + rowData.name)
},

// ...


来源:https://stackoverflow.com/questions/58267301/how-to-change-material-table-action-fields-icon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!