UNPKG

3.45 kBTypeScriptView Raw
1import * as React from 'react';
2import { TypographyProps } from '../Typography';
3import { OverridableComponent, OverrideProps } from '../OverridableComponent';
4
5export interface CardHeaderTypeMap<
6 Props = {},
7 DefaultComponent extends React.ElementType = 'div',
8 TitleTypographyComponent extends React.ElementType = 'span',
9 SubheaderTypographyComponent extends React.ElementType = 'span'
10> {
11 props: Props & {
12 /**
13 * The action to display in the card header.
14 */
15 action?: React.ReactNode;
16 /**
17 * The Avatar for the Card Header.
18 */
19 avatar?: React.ReactNode;
20 /**
21 * If `true`, `subheader` and `title` won't be wrapped by a Typography component.
22 * This can be useful to render an alternative Typography variant by wrapping
23 * the `title` text, and optional `subheader` text
24 * with the Typography component.
25 */
26 disableTypography?: boolean;
27 /**
28 * The content of the component.
29 */
30 subheader?: React.ReactNode;
31 /**
32 * These props will be forwarded to the subheader
33 * (as long as disableTypography is not `true`).
34 */
35 subheaderTypographyProps?: TypographyProps<
36 SubheaderTypographyComponent,
37 { component?: SubheaderTypographyComponent }
38 >;
39 /**
40 * The content of the Card Title.
41 */
42 title?: React.ReactNode;
43 /**
44 * These props will be forwarded to the title
45 * (as long as disableTypography is not `true`).
46 */
47 titleTypographyProps?: TypographyProps<
48 TitleTypographyComponent,
49 { component?: TitleTypographyComponent }
50 >;
51 };
52 defaultComponent: DefaultComponent;
53 classKey: CardHeaderClassKey;
54}
55/**
56 *
57 * Demos:
58 *
59 * - [Cards](https://mui.com/components/cards/)
60 *
61 * API:
62 *
63 * - [CardHeader API](https://mui.com/api/card-header/)
64 */
65declare const CardHeader: OverridableCardHeader;
66
67export interface OverridableCardHeader extends OverridableComponent<CardHeaderTypeMap> {
68 <
69 DefaultComponent extends React.ElementType = CardHeaderTypeMap['defaultComponent'],
70 Props = {},
71 TitleTypographyComponent extends React.ElementType = 'span',
72 SubheaderTypographyComponent extends React.ElementType = 'span'
73 >(
74 props: CardHeaderPropsWithComponent<
75 DefaultComponent,
76 Props,
77 TitleTypographyComponent,
78 SubheaderTypographyComponent
79 >
80 ): JSX.Element;
81}
82
83export type CardHeaderClassKey = 'root' | 'avatar' | 'action' | 'content' | 'title' | 'subheader';
84
85export type CardHeaderProps<
86 DefaultComponent extends React.ElementType = CardHeaderTypeMap['defaultComponent'],
87 Props = {},
88 TitleTypographyComponent extends React.ElementType = 'span',
89 SubheaderTypographyComponent extends React.ElementType = 'span'
90> = OverrideProps<
91 CardHeaderTypeMap<
92 Props,
93 DefaultComponent,
94 TitleTypographyComponent,
95 SubheaderTypographyComponent
96 >,
97 DefaultComponent
98>;
99
100export type CardHeaderPropsWithComponent<
101 DefaultComponent extends React.ElementType = CardHeaderTypeMap['defaultComponent'],
102 Props = {},
103 TitleTypographyComponent extends React.ElementType = 'span',
104 SubheaderTypographyComponent extends React.ElementType = 'span'
105> = {
106 /**
107 * The component used for the root node.
108 * Either a string to use a HTML element or a component.
109 */
110 component?: DefaultComponent;
111} & CardHeaderProps<
112 DefaultComponent,
113 Props,
114 TitleTypographyComponent,
115 SubheaderTypographyComponent
116>;
117
118export default CardHeader;