UNPKG

3.02 kBTypeScriptView Raw
1import * as React from 'react';
2import { SxProps } from '@mui/system';
3import { OverridableStringUnion } from '@mui/types';
4import { InternalStandardProps as StandardProps } from '..';
5import { Theme } from '../styles';
6import { ToggleButtonGroupClasses } from './toggleButtonGroupClasses';
7
8export interface ToggleButtonGroupPropsSizeOverrides {}
9
10export interface ToggleButtonGroupPropsColorOverrides {}
11
12export interface ToggleButtonGroupProps
13 extends StandardProps<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'children'> {
14 /**
15 * The content of the component.
16 */
17 children?: React.ReactNode;
18 /**
19 * Override or extend the styles applied to the component.
20 */
21 classes?: Partial<ToggleButtonGroupClasses>;
22 /**
23 * The color of the button when it is selected.
24 * It supports both default and custom theme colors, which can be added as shown in the
25 * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
26 * @default 'standard'
27 */
28 color?: OverridableStringUnion<
29 'standard' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning',
30 ToggleButtonGroupPropsColorOverrides
31 >;
32 /**
33 * If `true`, only allow one of the child ToggleButton values to be selected.
34 * @default false
35 */
36 exclusive?: boolean;
37 /**
38 * If `true`, the component is disabled. This implies that all ToggleButton children will be disabled.
39 * @default false
40 */
41 disabled?: boolean;
42 /**
43 * If `true`, the button group will take up the full width of its container.
44 * @default false
45 */
46 fullWidth?: boolean;
47 /**
48 * Callback fired when the value changes.
49 *
50 * @param {React.MouseEvent<HTMLElement>} event The event source of the callback.
51 * @param {any} value of the selected buttons. When `exclusive` is true
52 * this is a single value; when false an array of selected values. If no value
53 * is selected and `exclusive` is true the value is null; when false an empty array.
54 */
55 onChange?: (event: React.MouseEvent<HTMLElement>, value: any) => void;
56 /**
57 * The component orientation (layout flow direction).
58 * @default 'horizontal'
59 */
60 orientation?: 'horizontal' | 'vertical';
61 /**
62 * The size of the component.
63 * @default 'medium'
64 */
65 size?: OverridableStringUnion<'small' | 'medium' | 'large', ToggleButtonGroupPropsSizeOverrides>;
66 /**
67 * The system prop that allows defining system overrides as well as additional CSS styles.
68 */
69 sx?: SxProps<Theme>;
70 /**
71 * The currently selected value within the group or an array of selected
72 * values when `exclusive` is false.
73 *
74 * The value must have reference equality with the option in order to be selected.
75 */
76 value?: any;
77}
78
79/**
80 *
81 * Demos:
82 *
83 * - [Toggle Button](https://mui.com/material-ui/react-toggle-button/)
84 *
85 * API:
86 *
87 * - [ToggleButtonGroup API](https://mui.com/material-ui/api/toggle-button-group/)
88 */
89export default function ToggleButtonGroup(props: ToggleButtonGroupProps): React.JSX.Element;