UNPKG

3.6 kBTypeScriptView Raw
1import * as React from 'react';
2import { SxProps } from '@mui/system';
3import { OverridableStringUnion } from '@mui/types';
4import { Theme } from '../styles';
5import { OverridableComponent, OverrideProps } from '../OverridableComponent';
6import { SvgIconClasses } from './svgIconClasses';
7
8export interface SvgIconPropsSizeOverrides {}
9
10export interface SvgIconPropsColorOverrides {}
11
12export interface SvgIconOwnProps {
13 /**
14 * Node passed into the SVG element.
15 */
16 children?: React.ReactNode;
17 /**
18 * Override or extend the styles applied to the component.
19 */
20 classes?: Partial<SvgIconClasses>;
21 /**
22 * The color of the component.
23 * It supports both default and custom theme colors, which can be added as shown in the
24 * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
25 * You can use the `htmlColor` prop to apply a color attribute to the SVG element.
26 * @default 'inherit'
27 */
28 color?: OverridableStringUnion<
29 | 'inherit'
30 | 'action'
31 | 'disabled'
32 | 'primary'
33 | 'secondary'
34 | 'error'
35 | 'info'
36 | 'success'
37 | 'warning',
38 SvgIconPropsColorOverrides
39 >;
40 /**
41 * The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size.
42 * @default 'medium'
43 */
44 fontSize?: OverridableStringUnion<
45 'inherit' | 'large' | 'medium' | 'small',
46 SvgIconPropsSizeOverrides
47 >;
48 /**
49 * Applies a color attribute to the SVG element.
50 */
51 htmlColor?: string;
52 /**
53 * If `true`, the root node will inherit the custom `component`'s viewBox and the `viewBox`
54 * prop will be ignored.
55 * Useful when you want to reference a custom `component` and have `SvgIcon` pass that
56 * `component`'s viewBox to the root node.
57 * @default false
58 */
59 inheritViewBox?: boolean;
60 /**
61 * The shape-rendering attribute. The behavior of the different options is described on the
62 * [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering).
63 * If you are having issues with blurry icons you should investigate this prop.
64 */
65 shapeRendering?: string;
66 /**
67 * The system prop that allows defining system overrides as well as additional CSS styles.
68 */
69 sx?: SxProps<Theme>;
70 /**
71 * Provides a human-readable title for the element that contains it.
72 * https://www.w3.org/TR/SVG-access/#Equivalent
73 */
74 titleAccess?: string;
75 /**
76 * Allows you to redefine what the coordinates without units mean inside an SVG element.
77 * For example, if the SVG element is 500 (width) by 200 (height),
78 * and you pass viewBox="0 0 50 20",
79 * this means that the coordinates inside the SVG will go from the top left corner (0,0)
80 * to bottom right (50,20) and each unit will be worth 10px.
81 * @default '0 0 24 24'
82 */
83 viewBox?: string;
84}
85
86export interface SvgIconTypeMap<
87 AdditionalProps = {},
88 RootComponent extends React.ElementType = 'svg',
89> {
90 props: AdditionalProps & SvgIconOwnProps;
91 defaultComponent: RootComponent;
92}
93/**
94 *
95 * Demos:
96 *
97 * - [Icons](https://mui.com/material-ui/icons/)
98 * - [Material Icons](https://mui.com/material-ui/material-icons/)
99 *
100 * API:
101 *
102 * - [SvgIcon API](https://mui.com/material-ui/api/svg-icon/)
103 */
104declare const SvgIcon: OverridableComponent<SvgIconTypeMap> & { muiName: string };
105
106export type SvgIconProps<
107 RootComponent extends React.ElementType = SvgIconTypeMap['defaultComponent'],
108 AdditionalProps = {},
109> = OverrideProps<SvgIconTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
110 component?: React.ElementType;
111};
112
113export default SvgIcon;