UNPKG

2.05 kBTypeScriptView Raw
1import * as React from 'react';
2import { Simplify } from '@mui/types';
3import { UseButtonParameters, UseButtonRootSlotProps } from '../useButton';
4import { SlotComponentProps } from '../utils';
5import { PolymorphicProps } from '../utils/PolymorphicComponent';
6export interface ButtonActions {
7 focusVisible(): void;
8}
9export interface ButtonRootSlotPropsOverrides {
10}
11export interface ButtonOwnProps extends Omit<UseButtonParameters, 'rootRef'> {
12 /**
13 * A ref for imperative actions. It currently only supports `focusVisible()` action.
14 */
15 action?: React.Ref<ButtonActions>;
16 children?: React.ReactNode;
17 className?: string;
18 /**
19 * The props used for each slot inside the Button.
20 * @default {}
21 */
22 slotProps?: {
23 root?: SlotComponentProps<'button', ButtonRootSlotPropsOverrides, ButtonOwnerState>;
24 };
25 /**
26 * The components used for each slot inside the Button.
27 * Either a string to use a HTML element or a component.
28 * @default {}
29 */
30 slots?: ButtonSlots;
31 /**
32 * The HTML element that is ultimately rendered, for example 'button' or 'a'
33 * @default 'button'
34 */
35 rootElementName?: keyof HTMLElementTagNameMap;
36}
37export interface ButtonSlots {
38 /**
39 * The component that renders the root.
40 * @default props.href || props.to ? 'a' : 'button'
41 */
42 root?: React.ElementType;
43}
44export type ButtonProps<RootComponentType extends React.ElementType = ButtonTypeMap['defaultComponent']> = PolymorphicProps<ButtonTypeMap<{}, RootComponentType>, RootComponentType>;
45export interface ButtonTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'button'> {
46 props: ButtonOwnProps & AdditionalProps;
47 defaultComponent: RootComponentType;
48}
49export type ButtonOwnerState = Simplify<ButtonOwnProps & {
50 active: boolean;
51 focusVisible: boolean;
52}>;
53export type ButtonRootSlotProps = Simplify<UseButtonRootSlotProps & {
54 ownerState: ButtonOwnerState;
55 className?: string;
56 children?: React.ReactNode;
57}>;