UNPKG

3.9 kBTypeScriptView Raw
1import * as React from 'react';
2import { OverridableStringUnion } from '@mui/types';
3import { SxProps, SystemProps } from '@mui/system';
4import { Theme, TypeText } from '../styles';
5import { OverrideProps, OverridableComponent } from '../OverridableComponent';
6import { Variant } from '../styles/createTypography';
7import { TypographyClasses } from './typographyClasses';
8
9export interface TypographyPropsVariantOverrides {}
10
11export interface TypographyPropsColorOverrides {}
12
13export interface TypographyOwnProps extends Omit<SystemProps<Theme>, 'color'> {
14 /**
15 * Set the text-align on the component.
16 * @default 'inherit'
17 */
18 align?: 'inherit' | 'left' | 'center' | 'right' | 'justify';
19 /**
20 * The content of the component.
21 */
22 children?: React.ReactNode;
23 /**
24 * Override or extend the styles applied to the component.
25 */
26 classes?: Partial<TypographyClasses>;
27 /**
28 * The color of the component.
29 * It supports both default and custom theme colors, which can be added as shown in the
30 * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
31 */
32 color?:
33 | OverridableStringUnion<
34 | 'primary'
35 | 'secondary'
36 | 'success'
37 | 'error'
38 | 'info'
39 | 'warning'
40 | `text${Capitalize<keyof TypeText>}`,
41 TypographyPropsColorOverrides
42 >
43 | (string & {}); // to work with v5 color prop type which allows any string
44 /**
45 * If `true`, the text will have a bottom margin.
46 * @default false
47 */
48 gutterBottom?: boolean;
49 /**
50 * If `true`, the text will not wrap, but instead will truncate with a text overflow ellipsis.
51 *
52 * Note that text overflow can only happen with block or inline-block level elements
53 * (the element needs to have a width in order to overflow).
54 * @default false
55 */
56 noWrap?: boolean;
57 /**
58 * If `true`, the element will be a paragraph element.
59 * @default false
60 * @deprecated Use the `component` 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.
61 */
62 paragraph?: boolean;
63 /**
64 * The system prop that allows defining system overrides as well as additional CSS styles.
65 */
66 sx?: SxProps<Theme>;
67 /**
68 * Applies the theme typography styles.
69 * @default 'body1'
70 */
71 variant?: OverridableStringUnion<Variant | 'inherit', TypographyPropsVariantOverrides>;
72 /**
73 * The component maps the variant prop to a range of different HTML element types.
74 * For instance, subtitle1 to `<h6>`.
75 * If you wish to change that mapping, you can provide your own.
76 * Alternatively, you can use the `component` prop.
77 * @default {
78 * h1: 'h1',
79 * h2: 'h2',
80 * h3: 'h3',
81 * h4: 'h4',
82 * h5: 'h5',
83 * h6: 'h6',
84 * subtitle1: 'h6',
85 * subtitle2: 'h6',
86 * body1: 'p',
87 * body2: 'p',
88 * inherit: 'p',
89 * }
90 */
91 variantMapping?: Partial<
92 Record<OverridableStringUnion<Variant | 'inherit', TypographyPropsVariantOverrides>, string>
93 >;
94}
95
96export interface TypographyTypeMap<
97 AdditionalProps = {},
98 RootComponent extends React.ElementType = 'span',
99> {
100 props: AdditionalProps & TypographyOwnProps;
101 defaultComponent: RootComponent;
102}
103
104/**
105 *
106 * Demos:
107 *
108 * - [Breadcrumbs](https://mui.com/material-ui/react-breadcrumbs/)
109 * - [Typography](https://mui.com/material-ui/react-typography/)
110 *
111 * API:
112 *
113 * - [Typography API](https://mui.com/material-ui/api/typography/)
114 */
115declare const Typography: OverridableComponent<TypographyTypeMap>;
116
117export type TypographyProps<
118 RootComponent extends React.ElementType = TypographyTypeMap['defaultComponent'],
119 AdditionalProps = {},
120> = OverrideProps<TypographyTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
121 component?: React.ElementType;
122};
123
124export default Typography;