Skip to content

Commit 0e0f17e

Browse files
AbdullahElrubioliviertassinari
authored andcommitted
[Autocomplete] Add closeIcon and popupIcon props (#18266)
1 parent 779dbcf commit 0e0f17e

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

docs/pages/api/autocomplete.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
2929
| <span class="prop-name">autoSelect</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the selected option becomes the value of the input when the Autocomplete loses focus unless the user chooses a different option or changes the character string in the input. |
3030
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
3131
| <span class="prop-name">clearOnEscape</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, clear all values when the user presses escape and the popup is closed. |
32+
| <span class="prop-name">closeIcon</span> | <span class="prop-type">node</span> | <span class="prop-default">&lt;CloseIcon fontSize="small" /></span> | The icon to display in place of the default close icon. |
3233
| <span class="prop-name">debug</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the popup will ignore the blur event if the input if filled. You can inspect the popup markup with your browser tools. Consider this option when you need to customize the component. |
3334
| <span class="prop-name">defaultValue</span> | <span class="prop-type">any</span> | | The default input value. Use when the component is not controlled. |
3435
| <span class="prop-name">disableClearable</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the input can't be cleared. |
@@ -57,6 +58,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
5758
| <span class="prop-name">options</span> | <span class="prop-type">array</span> | <span class="prop-default">[]</span> | Array of options. |
5859
| <span class="prop-name">PaperComponent</span> | <span class="prop-type">elementType</span> | <span class="prop-default">Paper</span> | The component used to render the body of the popup. |
5960
| <span class="prop-name">PopperComponent</span> | <span class="prop-type">elementType</span> | <span class="prop-default">Popper</span> | The component used to position the popup. |
61+
| <span class="prop-name">popupIcon</span> | <span class="prop-type">node</span> | <span class="prop-default">&lt;ArrowDropDownIcon /></span> | The icon to display in place of the default popup icon. |
6062
| <span class="prop-name">renderGroup</span> | <span class="prop-type">func</span> | | Render the group.<br><br>**Signature:**<br>`function(option: any) => ReactNode`<br>*option:* The group to render. |
6163
| <span class="prop-name required">renderInput&nbsp;*</span> | <span class="prop-type">func</span> | | Render the input.<br><br>**Signature:**<br>`function(params: object) => ReactNode`<br>*params:* null |
6264
| <span class="prop-name">renderOption</span> | <span class="prop-type">func</span> | | Render the option, use `getOptionLabel` by default.<br><br>**Signature:**<br>`function(option: any, state: object) => ReactNode`<br>*option:* The option to render.<br>*state:* The state of the component. |

packages/material-ui-lab/src/Autocomplete/Autocomplete.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export interface AutocompleteProps
4141
AutocompleteClassKey,
4242
'defaultValue' | 'onChange' | 'children'
4343
> {
44+
/**
45+
* The icon to display in place of the default close icon.
46+
*/
47+
closeIcon?: React.ReactNode;
4448
/**
4549
* If `true`, the input will be disabled.
4650
*/
@@ -74,6 +78,10 @@ export interface AutocompleteProps
7478
* The component used to position the popup.
7579
*/
7680
PopperComponent?: React.ComponentType<PopperProps>;
81+
/**
82+
* The icon to display in place of the default popup icon.
83+
*/
84+
popupIcon?: React.ReactNode;
7785
/**
7886
* Render the group.
7987
*

packages/material-ui-lab/src/Autocomplete/Autocomplete.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
164164
classes,
165165
className,
166166
clearOnEscape = false,
167+
closeIcon = <CloseIcon fontSize="small" />,
167168
debug = false,
168169
defaultValue,
169170
disableClearable = false,
@@ -192,6 +193,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
192193
options = [],
193194
PaperComponent = Paper,
194195
PopperComponent: PopperComponentProp = Popper,
196+
popupIcon = <ArrowDropDownIcon />,
195197
renderGroup: renderGroupProp,
196198
renderInput,
197199
renderOption: renderOptionProp,
@@ -302,7 +304,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
302304
[classes.clearIndicatorDirty]: dirty,
303305
})}
304306
>
305-
<CloseIcon fontSize="small" />
307+
{closeIcon}
306308
</IconButton>
307309
)}
308310

@@ -315,7 +317,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
315317
[classes.popupIndicatorOpen]: popupOpen,
316318
})}
317319
>
318-
<ArrowDropDownIcon />
320+
{popupIcon}
319321
</IconButton>
320322
)}
321323
</React.Fragment>
@@ -404,6 +406,10 @@ Autocomplete.propTypes = {
404406
* If `true`, clear all values when the user presses escape and the popup is closed.
405407
*/
406408
clearOnEscape: PropTypes.bool,
409+
/**
410+
* The icon to display in place of the default close icon.
411+
*/
412+
closeIcon: PropTypes.node,
407413
/**
408414
* If `true`, the popup will ignore the blur event if the input if filled.
409415
* You can inspect the popup markup with your browser tools.
@@ -538,6 +544,10 @@ Autocomplete.propTypes = {
538544
* The component used to position the popup.
539545
*/
540546
PopperComponent: PropTypes.elementType,
547+
/**
548+
* The icon to display in place of the default popup icon.
549+
*/
550+
popupIcon: PropTypes.node,
541551
/**
542552
* Render the group.
543553
*

0 commit comments

Comments
 (0)