UNPKG

3.83 kBTypeScriptView Raw
1import * as React from 'react';
2import {
3 OverridableComponent,
4 OverridableStringUnion,
5 OverrideProps,
6 PartiallyRequired,
7} from '@mui/types';
8import { SxProps } from '@mui/system';
9import { Theme } from '@mui/material';
10import { AvatarGroupClasses } from './avatarGroupClasses';
11import Avatar from '../Avatar';
12import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
13
14export interface AvatarGroupPropsVariantOverrides {}
15
16export interface AvatarGroupComponentsPropsOverrides {}
17
18export interface AvatarGroupSlots {
19 surplus: React.ElementType;
20}
21
22export type AvatarGroupSlotsAndSlotProps = CreateSlotsAndSlotProps<
23 AvatarGroupSlots,
24 {
25 /**
26 * @deprecated use `slotProps.surplus` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
27 * */
28 additionalAvatar: React.ComponentPropsWithRef<typeof Avatar> &
29 AvatarGroupComponentsPropsOverrides;
30 surplus: SlotProps<
31 React.ElementType<React.ComponentPropsWithRef<typeof Avatar>>,
32 AvatarGroupComponentsPropsOverrides,
33 AvatarGroupOwnerState
34 >;
35 }
36>;
37export interface AvatarGroupOwnProps extends AvatarGroupSlotsAndSlotProps {
38 /**
39 * The avatars to stack.
40 */
41 children?: React.ReactNode;
42 /**
43 * Override or extend the styles applied to the component.
44 */
45 classes?: Partial<AvatarGroupClasses>;
46 /**
47 * The component used for the root node.
48 * Either a string to use a HTML element or a component.
49 */
50 component?: React.ElementType;
51 /**
52 * The extra props for the slot components.
53 * You can override the existing props or add new ones.
54 *
55 * This prop is an alias for the `slotProps` prop.
56 *
57 * @deprecated use the `slotProps` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
58 */
59 componentsProps?: {
60 additionalAvatar?: React.ComponentPropsWithRef<typeof Avatar> &
61 AvatarGroupComponentsPropsOverrides;
62 };
63 /**
64 * Max avatars to show before +x.
65 * @default 5
66 */
67 max?: number;
68 /**
69 * custom renderer of extraAvatars
70 * @param {number} surplus number of extra avatars
71 * @returns {React.ReactNode} custom element to display
72 */
73 renderSurplus?: (surplus: number) => React.ReactNode;
74 /**
75 * Spacing between avatars.
76 * @default 'medium'
77 */
78 spacing?: 'small' | 'medium' | number;
79 /**
80 * The system prop that allows defining system overrides as well as additional CSS styles.
81 */
82 sx?: SxProps<Theme>;
83 /**
84 * The total number of avatars. Used for calculating the number of extra avatars.
85 * @default children.length
86 */
87 total?: number;
88 /**
89 * The variant to use.
90 * @default 'circular'
91 */
92 variant?: OverridableStringUnion<
93 'circular' | 'rounded' | 'square',
94 AvatarGroupPropsVariantOverrides
95 >;
96}
97
98export interface AvatarGroupTypeMap<
99 AdditionalProps = {},
100 RootComponent extends React.ElementType = 'div',
101> {
102 props: AdditionalProps & AvatarGroupOwnProps;
103 defaultComponent: RootComponent;
104}
105
106/**
107 *
108 * Demos:
109 *
110 * - [Avatar](https://mui.com/material-ui/react-avatar/)
111 *
112 * API:
113 *
114 * - [AvatarGroup API](https://mui.com/material-ui/api/avatar-group/)
115 */
116declare const AvatarGroup: OverridableComponent<AvatarGroupTypeMap>;
117
118export type AvatarGroupProps<
119 RootComponent extends React.ElementType = AvatarGroupTypeMap['defaultComponent'],
120 AdditionalProps = {},
121> = OverrideProps<AvatarGroupTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
122 component?: React.ElementType;
123};
124
125export interface AvatarGroupOwnerState
126 extends PartiallyRequired<AvatarGroupProps, 'max' | 'spacing' | 'component' | 'variant'> {}
127
128export default AvatarGroup;