[英]REACTJs: How to change color and size of edit and delete icon in Material-Table?
我在我的项目中使用 Material-Table,我想更改编辑和删除图标的颜色和大小。 如何实现? 我附上这个问题的截图。
function Editable() {
const { useState } = React;
const [columns, setColumns] = useState([
{ title: 'Name', field: 'name' },
]);
const [data, setData] = useState([
{ name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 },
]);
return (
<MaterialTable
title="Editable Preview"
columns={columns}
data={data}
editable={{
//Code of add, update
}}
/>
)
}
您可以使用actions
道具创建自己的样式,然后根据需要设置样式
actions={[
{
icon: () => (
<Edit fontSize="large"
className={classes.edit}
/>
),
tooltip: 'Edit Item',
onClick: (event, rowData) => edit(rowData)
},
{
icon: () => (
<Delete fontSize="large"
className={classes.delete}
/>
),
tooltip: 'Delete Item',
onClick: (event, rowData) => delete(rowData),
},
]}
使用tableIcons 。
const tableIcons = {<br/>
Delete: forwardRef((props, ref) => <DeleteOutline {...props} ref={ref} style={{fontSize: 18}}/>),<br/>
Edit: forwardRef((props, ref) => <Edit {...props} ref={ref} style={{fontSize: 18}}/>),<br/>
};<br/>
<br/>
<MaterialTable icons={tableIcons} ... />
Material-table
允许您覆盖任何列的呈现,您可以直接在列中指定操作项,并进一步调用您需要的任何和所有onClick
事件。
const columns = [
{
render: rowData => (
<>
<IconButton>
<EditIcon style={{ color: 'green' }} />
</IconButton>
<IconButton>
<DeleteIcon style={{ color: 'yellow' }} />
</IconButton>
</>
),
sorting: false,
},
];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.