@@ -2,6 +2,11 @@ import * as React from 'react';
22import ActionList from '@mui/icons-material/List' ;
33import { Link } from 'react-router-dom' ;
44import { useResourceContext , useCreatePath , useCanAccess } from 'ra-core' ;
5+ import {
6+ ComponentsOverrides ,
7+ styled ,
8+ useThemeProps ,
9+ } from '@mui/material/styles' ;
510
611import { Button , ButtonProps } from './Button' ;
712
@@ -31,7 +36,12 @@ import { Button, ButtonProps } from './Button';
3136 * </Edit>
3237 * );
3338 */
34- export const ListButton = ( props : ListButtonProps ) => {
39+ export const ListButton = ( inProps : ListButtonProps ) => {
40+ const props = useThemeProps ( {
41+ props : inProps ,
42+ name : PREFIX ,
43+ } ) ;
44+
3545 const {
3646 icon = defaultIcon ,
3747 label = 'ra.action.list' ,
@@ -56,15 +66,15 @@ export const ListButton = (props: ListButtonProps) => {
5666 }
5767
5868 return (
59- < Button
69+ < StyledButton
6070 component = { Link }
6171 to = { createPath ( { type : 'list' , resource } ) }
6272 state = { scrollStates [ String ( scrollToTop ) ] }
6373 label = { label }
64- { ...( rest as any ) }
74+ { ...rest }
6575 >
6676 { icon }
67- </ Button >
77+ </ StyledButton >
6878 ) ;
6979} ;
7080
@@ -84,3 +94,29 @@ interface Props {
8494}
8595
8696export type ListButtonProps = Props & ButtonProps ;
97+
98+ const PREFIX = 'RaListButton' ;
99+
100+ const StyledButton = styled ( Button , {
101+ name : PREFIX ,
102+ overridesResolver : ( props , styles ) => styles . root ,
103+ } ) ( { } ) ;
104+
105+ declare module '@mui/material/styles' {
106+ interface ComponentNameToClassKey {
107+ [ PREFIX ] : 'root' ;
108+ }
109+
110+ interface ComponentsPropsList {
111+ [ PREFIX ] : Partial < ListButtonProps > ;
112+ }
113+
114+ interface Components {
115+ [ PREFIX ] ?: {
116+ defaultProps ?: ComponentsPropsList [ typeof PREFIX ] ;
117+ styleOverrides ?: ComponentsOverrides <
118+ Omit < Theme , 'components' >
119+ > [ typeof PREFIX ] ;
120+ } ;
121+ }
122+ }
0 commit comments