UNPKG

2.07 kBTypeScriptView Raw
1import * as React from 'react';
2import { OverridableComponent, OverrideProps } from '../OverridableComponent';
3
4export interface BadgeOrigin {
5 vertical: 'top' | 'bottom';
6 horizontal: 'left' | 'right';
7}
8
9export interface BadgeTypeMap<P = {}, D extends React.ElementType = 'div'> {
10 props: P & {
11 /**
12 * The anchor of the badge.
13 */
14 anchorOrigin?: BadgeOrigin;
15 /**
16 * Wrapped shape the badge should overlap.
17 */
18 overlap?: 'rectangle' | 'circle';
19 /**
20 * The content rendered within the badge.
21 */
22 badgeContent?: React.ReactNode;
23 /**
24 * The badge will be added relative to this node.
25 */
26 children?: React.ReactNode;
27 /**
28 * The color of the component. It supports those theme colors that make sense for this component.
29 */
30 color?: 'primary' | 'secondary' | 'default' | 'error';
31 /**
32 * If `true`, the badge will be invisible.
33 */
34 invisible?: boolean;
35 /**
36 * Max count to show.
37 */
38 max?: number;
39 /**
40 * Controls whether the badge is hidden when `badgeContent` is zero.
41 */
42 showZero?: boolean;
43 /**
44 * The variant to use.
45 */
46 variant?: 'standard' | 'dot';
47 };
48 defaultComponent: D;
49 classKey: BadgeClassKey;
50}
51
52export type BadgeClassKey =
53 | 'root'
54 | 'badge'
55 | 'colorPrimary'
56 | 'colorSecondary'
57 | 'colorError'
58 | 'dot'
59 | 'anchorOriginTopRightRectangle'
60 | 'anchorOriginBottomRightRectangle'
61 | 'anchorOriginTopLeftRectangle'
62 | 'anchorOriginBottomLeftRectangle'
63 | 'anchorOriginTopRightCircle'
64 | 'anchorOriginBottomRightCircle'
65 | 'anchorOriginTopLeftCircle'
66 | 'invisible';
67/**
68 *
69 * Demos:
70 *
71 * - [Avatars](https://material-ui.com/components/avatars/)
72 * - [Badges](https://material-ui.com/components/badges/)
73 *
74 * API:
75 *
76 * - [Badge API](https://material-ui.com/api/badge/)
77 */
78declare const Badge: OverridableComponent<BadgeTypeMap>;
79
80export type BadgeProps<
81 D extends React.ElementType = BadgeTypeMap['defaultComponent'],
82 P = {}
83> = OverrideProps<BadgeTypeMap<P, D>, D>;
84
85export default Badge;