Custom Icons Feature Guide
Mantine React Table uses Tabler Icons by default for all of its internal icons.
If you need to, you can customize and replace some or all of the icons with your own custom icons. You can either use other Tabler Icons or icons from a completely different library.
Relevant Table Options
Replace with Custom Icons
To replace a default icon, specify the icon in the
icons
prop. You should get TS hints for the name of the icons you can replace, but you can also consult this source file for a list of all the icons you can replace.const faIcons: Partial<MRT_Icons> = {//change sort icon, connect internal props so that it gets styled correctlyIconArrowDown: (props) => <FontAwesomeIcon icon={faSortDown} {...props} />,IconSearch: () => <FontAwesomeIcon icon={faSearch} />,IconArrowsSort: (props) => (<FontAwesomeIcon icon={faArrowDownWideShort} {...props} />),};const table = useMantineReactTable({columns,data,icons: faIcons,});
Some icons have
style
props that get applied to them internally. So, in order to preserve the ability of those Icons to be styled with the correct paddings, margins, or rotations, you should pass in {...props}
to your custom icon component as a best practice.Font Awesome Example
Here is an example where we use icons from a completely different library, Font Awesome.
Note: This example is only using the free solid icons from Font Awesome. If you want to use the pro icons, you will need to import the pro icons from Font Awesome and use those instead.
Actions | First Name | Last Name | Address | City | State |
---|---|---|---|---|---|
Dylan | Murray | 261 Erdman Ford | East Daphne | Kentucky | |
Raquel | Kohler | 769 Dominic Grove | Columbus | Ohio | |
Ervin | Reinger | 566 Brakus Inlet | South Linda | West Virginia | |
Brittany | McCullough | 722 Emie Stream | Lincoln | Nebraska | |
Branson | Frami | 32188 Larkin Turnpike | Charleston | South Carolina |
1-5 of 11
1import { useMemo } from 'react';2import {3MantineReactTable,4type MRT_ColumnDef,5type MRT_Icons,6} from 'mantine-react-table';7import { data, type Person } from './makeData';8import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';9import {10faAnglesDown,11faBars,12faBarsStaggered,13faChevronDown,14faChevronLeft,15faChevronRight,16faCircleXmark,17faColumns,18faCompress,19faEdit,20faEllipsisH,21faEllipsisV,22faExpand,23faEyeSlash,24faFilter,25faFilterCircleXmark,26faFloppyDisk,27faGrip,28faLayerGroup,29faSearch,30faSearchMinus,31faSort,32faSortDown,33faSortUp,34faTextWidth,35faThumbTack,36faX,37} from '@fortawesome/free-solid-svg-icons'; //replace free solid with your desired icon set38import '@fortawesome/fontawesome-svg-core/styles.css';39import { config } from '@fortawesome/fontawesome-svg-core';40config.autoAddCss = false;4142const fontAwesomeIcons: Partial<MRT_Icons> = {43IconArrowAutofitContent: (props: any) => (44<FontAwesomeIcon icon={faTextWidth} {...props} />45),46IconArrowsSort: (props: any) => <FontAwesomeIcon icon={faSort} {...props} />,47IconBoxMultiple: (props: any) => (48<FontAwesomeIcon icon={faLayerGroup} {...props} />49),50IconChevronDown: (props: any) => (51<FontAwesomeIcon icon={faChevronDown} {...props} />52),53IconChevronLeft: (props: any) => (54<FontAwesomeIcon icon={faChevronLeft} {...props} />55),56IconChevronRight: (props: any) => (57<FontAwesomeIcon icon={faChevronRight} {...props} />58),59IconChevronsDown: (props: any) => (60<FontAwesomeIcon icon={faAnglesDown} {...props} />61),62IconCircleX: (props: any) => (63<FontAwesomeIcon icon={faCircleXmark} {...props} />64),65IconClearAll: (props: any) => (66<FontAwesomeIcon icon={faBarsStaggered} {...props} />67),68IconColumns: (props: any) => <FontAwesomeIcon icon={faColumns} {...props} />,69IconDeviceFloppy: (props: any) => (70<FontAwesomeIcon icon={faFloppyDisk} {...props} />71),72IconDots: (props: any) => <FontAwesomeIcon icon={faEllipsisH} {...props} />,73IconDotsVertical: (props: any) => (74<FontAwesomeIcon icon={faEllipsisV} {...props} />75),76IconEdit: (props: any) => <FontAwesomeIcon icon={faEdit} {...props} />,77IconEyeOff: (props: any) => <FontAwesomeIcon icon={faEyeSlash} {...props} />,78IconFilter: (props: any) => <FontAwesomeIcon icon={faFilter} {...props} />,79IconFilterOff: (props: any) => (80<FontAwesomeIcon icon={faFilterCircleXmark} {...props} />81),82IconGripHorizontal: (props: any) => (83<FontAwesomeIcon icon={faGrip} {...props} />84),85IconMaximize: (props: any) => <FontAwesomeIcon icon={faExpand} {...props} />,86IconMinimize: (props: any) => (87<FontAwesomeIcon icon={faCompress} {...props} />88),89IconPinned: (props: any) => <FontAwesomeIcon icon={faThumbTack} {...props} />,90IconPinnedOff: (props: any) => (91<FontAwesomeIcon icon={faThumbTack} {...props} />92),93IconSearch: (props: any) => <FontAwesomeIcon icon={faSearch} {...props} />,94IconSearchOff: (props: any) => (95<FontAwesomeIcon icon={faSearchMinus} {...props} />96),97IconSortAscending: (props: any) => (98<FontAwesomeIcon icon={faSortUp} {...props} />99),100IconSortDescending: (props: any) => (101<FontAwesomeIcon icon={faSortDown} {...props} />102),103IconBaselineDensityLarge: (props: any) => (104<FontAwesomeIcon icon={faBars} {...props} />105),106IconBaselineDensityMedium: (props: any) => (107<FontAwesomeIcon icon={faBars} {...props} />108),109IconBaselineDensitySmall: (props: any) => (110<FontAwesomeIcon icon={faBars} {...props} />111),112IconX: (props: any) => <FontAwesomeIcon icon={faX} {...props} />,113};114115const Example = () => {116const columns = useMemo<MRT_ColumnDef<Person>[]>(117() => [118{119accessorKey: 'firstName',120header: 'First Name',121},122{123accessorKey: 'lastName',124header: 'Last Name',125},126127{128accessorKey: 'address',129header: 'Address',130},131{132accessorKey: 'city',133header: 'City',134},135136{137accessorKey: 'state',138header: 'State',139},140],141[],142);143144return (145<MantineReactTable146columns={columns}147data={data}148editDisplayMode="row"149enableColumnFilterModes150enableColumnOrdering151enableColumnResizing152enableEditing153enableGrouping154enablePinning155icons={fontAwesomeIcons}156initialState={{ pagination: { pageSize: 5, pageIndex: 0 } }}157/>158);159};160161export default Example;
1import { useMemo } from 'react';2import { MantineReactTable } from 'mantine-react-table';3import { data } from './makeData';4import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';5import {6faAnglesDown,7faBars,8faBarsStaggered,9faChevronDown,10faChevronLeft,11faChevronRight,12faCircleXmark,13faColumns,14faCompress,15faEdit,16faEllipsisH,17faEllipsisV,18faExpand,19faEyeSlash,20faFilter,21faFilterCircleXmark,22faFloppyDisk,23faGrip,24faLayerGroup,25faSearch,26faSearchMinus,27faSort,28faSortDown,29faSortUp,30faTextWidth,31faThumbTack,32faX,33} from '@fortawesome/free-solid-svg-icons'; //replace free solid with your desired icon set34import '@fortawesome/fontawesome-svg-core/styles.css';35import { config } from '@fortawesome/fontawesome-svg-core';36config.autoAddCss = false;3738const fontAwesomeIcons = {39IconArrowAutofitContent: (props) => (40<FontAwesomeIcon icon={faTextWidth} {...props} />41),42IconArrowsSort: (props) => <FontAwesomeIcon icon={faSort} {...props} />,43IconBoxMultiple: (props) => (44<FontAwesomeIcon icon={faLayerGroup} {...props} />45),46IconChevronDown: (props) => (47<FontAwesomeIcon icon={faChevronDown} {...props} />48),49IconChevronLeft: (props) => (50<FontAwesomeIcon icon={faChevronLeft} {...props} />51),52IconChevronRight: (props) => (53<FontAwesomeIcon icon={faChevronRight} {...props} />54),55IconChevronsDown: (props) => (56<FontAwesomeIcon icon={faAnglesDown} {...props} />57),58IconCircleX: (props) => <FontAwesomeIcon icon={faCircleXmark} {...props} />,59IconClearAll: (props) => (60<FontAwesomeIcon icon={faBarsStaggered} {...props} />61),62IconColumns: (props) => <FontAwesomeIcon icon={faColumns} {...props} />,63IconDeviceFloppy: (props) => (64<FontAwesomeIcon icon={faFloppyDisk} {...props} />65),66IconDots: (props) => <FontAwesomeIcon icon={faEllipsisH} {...props} />,67IconDotsVertical: (props) => (68<FontAwesomeIcon icon={faEllipsisV} {...props} />69),70IconEdit: (props) => <FontAwesomeIcon icon={faEdit} {...props} />,71IconEyeOff: (props) => <FontAwesomeIcon icon={faEyeSlash} {...props} />,72IconFilter: (props) => <FontAwesomeIcon icon={faFilter} {...props} />,73IconFilterOff: (props) => (74<FontAwesomeIcon icon={faFilterCircleXmark} {...props} />75),76IconGripHorizontal: (props) => <FontAwesomeIcon icon={faGrip} {...props} />,77IconMaximize: (props) => <FontAwesomeIcon icon={faExpand} {...props} />,78IconMinimize: (props) => <FontAwesomeIcon icon={faCompress} {...props} />,79IconPinned: (props) => <FontAwesomeIcon icon={faThumbTack} {...props} />,80IconPinnedOff: (props) => <FontAwesomeIcon icon={faThumbTack} {...props} />,81IconSearch: (props) => <FontAwesomeIcon icon={faSearch} {...props} />,82IconSearchOff: (props) => <FontAwesomeIcon icon={faSearchMinus} {...props} />,83IconSortAscending: (props) => <FontAwesomeIcon icon={faSortUp} {...props} />,84IconSortDescending: (props) => (85<FontAwesomeIcon icon={faSortDown} {...props} />86),87IconBaselineDensityLarge: (props) => (88<FontAwesomeIcon icon={faBars} {...props} />89),90IconBaselineDensityMedium: (props) => (91<FontAwesomeIcon icon={faBars} {...props} />92),93IconBaselineDensitySmall: (props) => (94<FontAwesomeIcon icon={faBars} {...props} />95),96IconX: (props) => <FontAwesomeIcon icon={faX} {...props} />,97};9899const Example = () => {100const columns = useMemo(101() => [102{103accessorKey: 'firstName',104header: 'First Name',105},106{107accessorKey: 'lastName',108header: 'Last Name',109},110111{112accessorKey: 'address',113header: 'Address',114},115{116accessorKey: 'city',117header: 'City',118},119120{121accessorKey: 'state',122header: 'State',123},124],125[],126);127128return (129<MantineReactTable130columns={columns}131data={data}132editDisplayMode="row"133enableColumnFilterModes134enableColumnOrdering135enableColumnResizing136enableEditing137enableGrouping138enablePinning139icons={fontAwesomeIcons}140initialState={{ pagination: { pageSize: 5, pageIndex: 0 } }}141/>142);143};144145export default Example;