@@ -9,6 +9,11 @@ import {
99 useCreatePath ,
1010 useCanAccess ,
1111} from 'ra-core' ;
12+ import {
13+ ComponentsOverrides ,
14+ styled ,
15+ useThemeProps ,
16+ } from '@mui/material/styles' ;
1217
1318import { Button , ButtonProps } from './Button' ;
1419
@@ -26,8 +31,13 @@ import { Button, ButtonProps } from './Button';
2631 * };
2732 */
2833const ShowButton = < RecordType extends RaRecord = any > (
29- props : ShowButtonProps < RecordType >
34+ inProps : ShowButtonProps < RecordType >
3035) => {
36+ const props = useThemeProps ( {
37+ props : inProps ,
38+ name : PREFIX ,
39+ } ) ;
40+
3141 const {
3242 icon = defaultIcon ,
3343 label = 'ra.action.show' ,
@@ -51,7 +61,7 @@ const ShowButton = <RecordType extends RaRecord = any>(
5161 } ) ;
5262 if ( ! record || ! canAccess || isPending ) return null ;
5363 return (
54- < Button
64+ < StyledButton
5565 component = { Link }
5666 to = { createPath ( { type : 'show' , resource, id : record . id } ) }
5767 state = { scrollStates [ String ( scrollToTop ) ] }
@@ -60,7 +70,7 @@ const ShowButton = <RecordType extends RaRecord = any>(
6070 { ...( rest as any ) }
6171 >
6272 { icon }
63- </ Button >
73+ </ StyledButton >
6474 ) ;
6575} ;
6676
@@ -98,3 +108,29 @@ const PureShowButton = memo(
98108) ;
99109
100110export default PureShowButton ;
111+
112+ const PREFIX = 'RaShowButton' ;
113+
114+ const StyledButton = styled ( Button , {
115+ name : PREFIX ,
116+ overridesResolver : ( props , styles ) => styles . root ,
117+ } ) ( { } ) ;
118+
119+ declare module '@mui/material/styles' {
120+ interface ComponentNameToClassKey {
121+ [ PREFIX ] : 'root' ;
122+ }
123+
124+ interface ComponentsPropsList {
125+ [ PREFIX ] : Partial < ShowButtonProps > ;
126+ }
127+
128+ interface Components {
129+ [ PREFIX ] ?: {
130+ defaultProps ?: ComponentsPropsList [ typeof PREFIX ] ;
131+ styleOverrides ?: ComponentsOverrides <
132+ Omit < Theme , 'components' >
133+ > [ typeof PREFIX ] ;
134+ } ;
135+ }
136+ }
0 commit comments