Do not require material icons to be imported from remote
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] Often a project already has material-ui/icons in node_modules, so there is no need to load it from a remote resource and as pollute the global space.
Describe the solution you'd like A clear and concise description of what you want to happen. The required icons should already either be part of the library or can be imported directly where material-table is being used.
example:
import React, { Fragment, memo } from 'react'
import MaterialTable from 'material-table'
import Icons from '@material-ui/icons'
const myTable = ({ data }) => (
<Fragment>
<MaterialTable
Icons={Icons}
columns={[
{ title: 'Profile Id', field: 'idGiver', type: 'numeric' },
{ title: 'Name', field: 'name' },
{ title: 'Url', field: 'url' },
{ title: 'Commit Time', field: 'commitTime', type: 'numeric' },
{ title: 'cancel', field: 'canceled' }
]}
data={data}
title="Funding Profiles"
/>
</Fragment>
)
export default memo(myTable)
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
Very clear alternative to cdn import. I will try and do this. Thank @bgits
im having issues doing this/it's not working as advertised. I used the code above (except the property icons needs to be lower case). But then it gives this error:
TS2739: Type 'typeof import("/Users/michael/path/to/projecti/node_modules/@material-ui/icons/index")' is missing the following properties from type 'Icons': DetailPanel, Export, NextPage, PreviousPage, ThirdStateCheck
So then I do something like:
import {
Search,
ViewColumn,
SaveAlt,
ChevronLeft,
ChevronRight,
FirstPage,
LastPage,
Add,
Check,
FilterList,
Remove,
} from '@material-ui/icons'
...
icons={
Check: Check,
DetailPanel: ChevronRight,
Export: SaveAlt,
Filter: FilterList,
FirstPage: FirstPage,
LastPage: LastPage,
NextPage: ChevronRight,
PreviousPage: ChevronLeft,
Search: Search,
ThirdStateCheck: Remove,
}
That fails with:
TS2322: Type '{ Check: ComponentType<SvgIconProps>; DetailPanel: ComponentType<SvgIconProps>; Export: ComponentType<SvgIconProps>; Filter: ComponentType<SvgIconProps>; FirstPage: ComponentType<SvgIconProps>; ... 5 more ...; ViewColumn: ComponentType<...>; }' is not assignable to type 'Icons'.
Types of property 'Check' are incompatible.
Type 'ComponentType<SvgIconProps>' is not assignable to type '() => ReactElement<any>'.
Type 'ComponentClass<SvgIconProps, any>' is not assignable to type '() => ReactElement<any>'.
Type 'ComponentClass<SvgIconProps, any>' provides no match for the signature '(): ReactElement<any>'.
How does one use this feature? Thanks much for you response.
this worked:
import { SvgIconProps } from '@material-ui/core/SvgIcon'
import Search from '@material-ui/icons/Search'
import ViewColumn from '@material-ui/icons/ViewColumn'
import SaveAlt from '@material-ui/icons/SaveAlt'
import ChevronLeft from '@material-ui/icons/ChevronLeft'
import ChevronRight from '@material-ui/icons/ChevronRight'
import FirstPage from '@material-ui/icons/FirstPage'
import LastPage from '@material-ui/icons/LastPage'
import Add from '@material-ui/icons/Add'
import Check from '@material-ui/icons/Check'
import FilterList from '@material-ui/icons/FilterList'
import Remove from '@material-ui/icons/Remove'
import MaterialTable from 'material-table';
...
<MaterialTable
icons={{
Check: () => <Check /> as React.ReactElement<SvgIconProps>,
Export: () => <SaveAlt /> as React.ReactElement<SvgIconProps>,
Filter: () => <FilterList /> as React.ReactElement<SvgIconProps>,
FirstPage: () => <FirstPage /> as React.ReactElement<SvgIconProps>,
LastPage: () => <LastPage /> as React.ReactElement<SvgIconProps>,
NextPage: () => <ChevronRight /> as React.ReactElement<SvgIconProps>,
PreviousPage: () => <ChevronLeft /> as React.ReactElement<SvgIconProps>,
Search: () => <Search /> as React.ReactElement<SvgIconProps>,
ThirdStateCheck: () => <Remove /> as React.ReactElement<SvgIconProps>,
ViewColumn: () => <ViewColumn /> as React.ReactElement<SvgIconProps>,
DetailPanel: () => <ChevronRight /> as React.ReactElement<SvgIconProps>,
}}
Thank you! It worked
import Search from '@material-ui/icons/Search'
import ViewColumn from '@material-ui/icons/ViewColumn'
import SaveAlt from '@material-ui/icons/SaveAlt'
import ChevronLeft from '@material-ui/icons/ChevronLeft'
import ChevronRight from '@material-ui/icons/ChevronRight'
import FirstPage from '@material-ui/icons/FirstPage'
import LastPage from '@material-ui/icons/LastPage'
import Add from '@material-ui/icons/Add'
import Check from '@material-ui/icons/Check'
import FilterList from '@material-ui/icons/FilterList'
import Remove from '@material-ui/icons/Remove'
import MaterialTable from 'material-table';
...
<MaterialTable
icons={{
Check: Check,
DetailPanel: ChevronRight,
Export: SaveAlt,
Filter: FilterList,
FirstPage: FirstPage,
LastPage: LastPage,
NextPage: ChevronRight,
PreviousPage: ChevronLeft,
Search: Search,
ThirdStateCheck: Remove,
}}
Specifying icons and using Editable together will result in an error. Is there a way to use it together?
https://mbrn.github.io/material-table/#/docz-examples-15-example-editable

It should be resolved with latest versions.
i need diffrent icon on each filter.
A complete version:
import Search from "@material-ui/icons/Search";
import ViewColumn from "@material-ui/icons/ViewColumn";
import SaveAlt from "@material-ui/icons/SaveAlt";
import ChevronLeft from "@material-ui/icons/ChevronLeft";
import ChevronRight from "@material-ui/icons/ChevronRight";
import FirstPage from "@material-ui/icons/FirstPage";
import LastPage from "@material-ui/icons/LastPage";
import Add from "@material-ui/icons/Add";
import Check from "@material-ui/icons/Check";
import FilterList from "@material-ui/icons/FilterList";
import Remove from "@material-ui/icons/Remove";
import ArrowDownward from "@material-ui/icons/ArrowDownward";
import Clear from "@material-ui/icons/Clear";
import DeleteOutline from "@material-ui/icons/DeleteOutline";
import Edit from "@material-ui/icons/Edit";
export default {
Check: Check,
DetailPanel: ChevronRight,
Delete: DeleteOutline,
Export: SaveAlt,
Filter: FilterList,
FirstPage: FirstPage,
LastPage: LastPage,
NextPage: ChevronRight,
PreviousPage: ChevronLeft,
Search: Search,
ThirdStateCheck: Remove,
Add: Add,
SortArrow: ArrowDownward,
Clear: Clear,
Edit: Edit,
ViewColumn: ViewColumn
};
My icon Clear does not render, How do I do? My version: "@material-ui/core": "^4.9.5", "@material-ui/icons": "^4.9.1", "@material-ui/styles": "^4.9.0", "material-table": "^1.57.2",
@CristianaYasuda check the way you're importing the icons and the version, in my project I'm using the same version that you're for the Material Table and the version 4.5.1 for the Material UI Icons
@CristianaYasuda Follow the instructions described in the README.md, they are more up-to-date than the comments in this thread.
https://github.com/mbrn/material-table#installation
Is it completely necessary to import the icons? Why cant the icons just be used by default? It's kind of annoying to have to specify these icons whenever i make a table.
@matthewcoding0 agree!