Skip to content

Commit ac0a22b

Browse files
committed
Allow to theme BulkExportButton and set its default props.
1 parent a0ddb4f commit ac0a22b

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

packages/ra-ui-materialui/src/button/BulkExportButton.tsx

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import {
99
useListContext,
1010
useResourceContext,
1111
} from 'ra-core';
12+
import {
13+
ComponentsOverrides,
14+
styled,
15+
useThemeProps,
16+
} from '@mui/material/styles';
1217

1318
import { Button, ButtonProps } from './Button';
1419

@@ -35,7 +40,12 @@ import { Button, ButtonProps } from './Button';
3540
* </List>
3641
* );
3742
*/
38-
export const BulkExportButton = (props: BulkExportButtonProps) => {
43+
export const BulkExportButton = (inProps: BulkExportButtonProps) => {
44+
const props = useThemeProps({
45+
props: inProps,
46+
name: PREFIX,
47+
});
48+
3949
const {
4050
onClick,
4151
label = 'ra.action.export',
@@ -77,13 +87,13 @@ export const BulkExportButton = (props: BulkExportButtonProps) => {
7787
);
7888

7989
return (
80-
<Button
90+
<StyledButton
8191
onClick={handleClick}
8292
label={label}
8393
{...sanitizeRestProps(rest)}
8494
>
8595
{icon}
86-
</Button>
96+
</StyledButton>
8797
);
8898
};
8999

@@ -104,3 +114,29 @@ interface Props {
104114
}
105115

106116
export type BulkExportButtonProps = Props & ButtonProps;
117+
118+
const PREFIX = 'RaBulkExportButton';
119+
120+
const StyledButton = styled(Button, {
121+
name: PREFIX,
122+
overridesResolver: (props, styles) => styles.root,
123+
})({});
124+
125+
declare module '@mui/material/styles' {
126+
interface ComponentNameToClassKey {
127+
[PREFIX]: 'root';
128+
}
129+
130+
interface ComponentsPropsList {
131+
[PREFIX]: Partial<BulkExportButtonProps>;
132+
}
133+
134+
interface Components {
135+
[PREFIX]?: {
136+
defaultProps?: ComponentsPropsList[typeof PREFIX];
137+
styleOverrides?: ComponentsOverrides<
138+
Omit<Theme, 'components'>
139+
>[typeof PREFIX];
140+
};
141+
}
142+
}

0 commit comments

Comments
 (0)