UNPKG

@mui/material

Version:

Quickly build beautiful React apps. MUI is a simple and customizable component library to build faster, beautiful, and more accessible React applications. Follow your own design system, or start with Material Design.

129 lines (119 loc) 3.75 kB
import * as React from 'react'; import { DistributiveOmit, OverridableStringUnion } from '@mui/types'; import { SxProps } from '@mui/system'; import { Theme } from '../styles'; import { ExtendButtonBase, ExtendButtonBaseTypeMap } from '../ButtonBase'; import { OverrideProps, OverridableComponent, OverridableTypeMap } from '../OverridableComponent'; import { ButtonClasses } from './buttonClasses'; export interface ButtonPropsVariantOverrides {} export interface ButtonPropsColorOverrides {} export interface ButtonPropsSizeOverrides {} export type ButtonTypeMap< P = {}, D extends React.ElementType = 'button', > = ExtendButtonBaseTypeMap<{ props: P & { /** * The content of the component. */ children?: React.ReactNode; /** * Override or extend the styles applied to the component. */ classes?: Partial<ButtonClasses>; /** * The color of the component. It supports those theme colors that make sense for this component. * @default 'primary' */ color?: OverridableStringUnion< 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning', ButtonPropsColorOverrides >; /** * If `true`, the component is disabled. * @default false */ disabled?: boolean; /** * If `true`, no elevation is used. * @default false */ disableElevation?: boolean; /** * If `true`, the keyboard focus ripple is disabled. * @default false */ disableFocusRipple?: boolean; /** * Element placed after the children. */ endIcon?: React.ReactNode; /** * If `true`, the button will take up the full width of its container. * @default false */ fullWidth?: boolean; /** * The URL to link to when the button is clicked. * If defined, an `a` element will be used as the root node. */ href?: string; /** * The size of the component. * `small` is equivalent to the dense button styling. * @default 'medium' */ size?: OverridableStringUnion<'small' | 'medium' | 'large', ButtonPropsSizeOverrides>; /** * Element placed before the children. */ startIcon?: React.ReactNode; /** * The system prop that allows defining system overrides as well as additional CSS styles. */ sx?: SxProps<Theme>; /** * The variant to use. * @default 'text' */ variant?: OverridableStringUnion< 'text' | 'outlined' | 'contained', ButtonPropsVariantOverrides >; }; defaultComponent: D; }>; /** * utility to create component types that inherit props from ButtonBase. * This component has an additional overload if the `href` prop is set which * can make extension quite tricky */ export interface ExtendButtonTypeMap<M extends OverridableTypeMap> { props: M['props'] & (M['props'] extends { classes?: Record<string, string> } ? DistributiveOmit<ButtonTypeMap['props'], 'classes'> : ButtonTypeMap['props']); defaultComponent: M['defaultComponent']; } export type ExtendButton<M extends OverridableTypeMap> = (( props: { href: string } & OverrideProps<ExtendButtonBaseTypeMap<M>, 'a'>, ) => JSX.Element) & OverridableComponent<ExtendButtonBaseTypeMap<M>>; /** * * Demos: * * - [Button Group](https://mui.com/components/button-group/) * - [Buttons](https://mui.com/components/buttons/) * * API: * * - [Button API](https://mui.com/api/button/) * - inherits [ButtonBase API](https://mui.com/api/button-base/) */ declare const Button: ExtendButtonBase<ButtonTypeMap>; export type ButtonProps< D extends React.ElementType = ButtonTypeMap['defaultComponent'], P = {}, > = OverrideProps<ButtonTypeMap<P, D>, D>; export default Button;