UNPKG

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