UNPKG

1.75 kBTypeScriptView Raw
1import * as React from 'react';
2import { OverridableComponent, OverrideProps } from '../OverridableComponent';
3
4export interface AvatarTypeMap<P = {}, D extends React.ElementType = 'div'> {
5 props: P & {
6 /**
7 * Used in combination with `src` or `srcSet` to
8 * provide an alt attribute for the rendered `img` element.
9 */
10 alt?: string;
11 /**
12 * Used to render icon or text elements inside the Avatar if `src` is not set.
13 * This can be an element, or just a string.
14 */
15 children?: React.ReactNode;
16 /**
17 * Attributes applied to the `img` element if the component is used to display an image.
18 * It can be used to listen for the loading error event.
19 */
20 imgProps?: React.ImgHTMLAttributes<HTMLImageElement>;
21 /**
22 * The `sizes` attribute for the `img` element.
23 */
24 sizes?: string;
25 /**
26 * The `src` attribute for the `img` element.
27 */
28 src?: string;
29 /**
30 * The `srcSet` attribute for the `img` element.
31 * Use this attribute for responsive image display.
32 */
33 srcSet?: string;
34 /**
35 * The shape of the avatar.
36 */
37 variant?: 'circle' | 'circular' | 'rounded' | 'square';
38 };
39 defaultComponent: D;
40 classKey: AvatarClassKey;
41}
42
43/**
44 *
45 * Demos:
46 *
47 * - [Avatars](https://mui.com/components/avatars/)
48 *
49 * API:
50 *
51 * - [Avatar API](https://mui.com/api/avatar/)
52 */
53declare const Avatar: OverridableComponent<AvatarTypeMap>;
54
55export type AvatarClassKey =
56 | 'root'
57 | 'colorDefault'
58 | 'circle'
59 | 'circular'
60 | 'rounded'
61 | 'square'
62 | 'img'
63 | 'fallback';
64
65export type AvatarProps<
66 D extends React.ElementType = AvatarTypeMap['defaultComponent'],
67 P = {}
68> = OverrideProps<AvatarTypeMap<P, D>, D>;
69
70export default Avatar;