Skip to content

Commit 63d13e5

Browse files
committed
[docs] Replace Checkbox with Icons in Combobox examples
1 parent 927830e commit 63d13e5

4 files changed

Lines changed: 42 additions & 32 deletions

File tree

docs/data/material/components/autocomplete/CheckboxesTags.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import Checkbox from '@mui/material/Checkbox';
21
import TextField from '@mui/material/TextField';
32
import Autocomplete from '@mui/material/Autocomplete';
43
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
54
import CheckBoxIcon from '@mui/icons-material/CheckBox';
65

7-
const icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
8-
const checkedIcon = <CheckBoxIcon fontSize="small" />;
9-
106
export default function CheckboxesTags() {
117
return (
128
<Autocomplete
@@ -17,13 +13,13 @@ export default function CheckboxesTags() {
1713
getOptionLabel={(option) => option.title}
1814
renderOption={(props, option, { selected }) => {
1915
const { key, ...optionProps } = props;
16+
const SelectionIcon = selected ? CheckBoxIcon : CheckBoxOutlineBlankIcon;
17+
2018
return (
2119
<li key={key} {...optionProps}>
22-
<Checkbox
23-
icon={icon}
24-
checkedIcon={checkedIcon}
25-
style={{ marginRight: 8 }}
26-
checked={selected}
20+
<SelectionIcon
21+
fontSize="small"
22+
style={{ marginRight: 8, padding: 9, boxSizing: 'content-box' }}
2723
/>
2824
{option.title}
2925
</li>

docs/data/material/components/autocomplete/CheckboxesTags.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import Checkbox from '@mui/material/Checkbox';
21
import TextField from '@mui/material/TextField';
32
import Autocomplete from '@mui/material/Autocomplete';
43
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
54
import CheckBoxIcon from '@mui/icons-material/CheckBox';
65

7-
const icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
8-
const checkedIcon = <CheckBoxIcon fontSize="small" />;
9-
106
export default function CheckboxesTags() {
117
return (
128
<Autocomplete
@@ -17,13 +13,13 @@ export default function CheckboxesTags() {
1713
getOptionLabel={(option) => option.title}
1814
renderOption={(props, option, { selected }) => {
1915
const { key, ...optionProps } = props;
16+
const SelectionIcon = selected ? CheckBoxIcon : CheckBoxOutlineBlankIcon;
17+
2018
return (
2119
<li key={key} {...optionProps}>
22-
<Checkbox
23-
icon={icon}
24-
checkedIcon={checkedIcon}
25-
style={{ marginRight: 8 }}
26-
checked={selected}
20+
<SelectionIcon
21+
fontSize="small"
22+
style={{ marginRight: 8, padding: 9, boxSizing: 'content-box' }}
2723
/>
2824
{option.title}
2925
</li>

docs/data/material/components/selects/MultipleSelectCheckmarks.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import MenuItem from '@mui/material/MenuItem';
55
import FormControl from '@mui/material/FormControl';
66
import ListItemText from '@mui/material/ListItemText';
77
import Select from '@mui/material/Select';
8-
import Checkbox from '@mui/material/Checkbox';
8+
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
9+
import CheckBoxIcon from '@mui/icons-material/CheckBox';
910

1011
const ITEM_HEIGHT = 48;
1112
const ITEM_PADDING_TOP = 8;
@@ -58,12 +59,20 @@ export default function MultipleSelectCheckmarks() {
5859
renderValue={(selected) => selected.join(', ')}
5960
MenuProps={MenuProps}
6061
>
61-
{names.map((name) => (
62-
<MenuItem key={name} value={name}>
63-
<Checkbox checked={personName.includes(name)} />
64-
<ListItemText primary={name} />
65-
</MenuItem>
66-
))}
62+
{names.map((name) => {
63+
const selected = personName.includes(name);
64+
const SelectionIcon = selected ? CheckBoxIcon : CheckBoxOutlineBlankIcon;
65+
66+
return (
67+
<MenuItem key={name} value={name}>
68+
<SelectionIcon
69+
fontSize="small"
70+
style={{ marginRight: 8, padding: 9, boxSizing: 'content-box' }}
71+
/>
72+
<ListItemText primary={name} />
73+
</MenuItem>
74+
);
75+
})}
6776
</Select>
6877
</FormControl>
6978
</div>

docs/data/material/components/selects/MultipleSelectCheckmarks.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import MenuItem from '@mui/material/MenuItem';
55
import FormControl from '@mui/material/FormControl';
66
import ListItemText from '@mui/material/ListItemText';
77
import Select, { SelectChangeEvent } from '@mui/material/Select';
8-
import Checkbox from '@mui/material/Checkbox';
8+
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
9+
import CheckBoxIcon from '@mui/icons-material/CheckBox';
910

1011
const ITEM_HEIGHT = 48;
1112
const ITEM_PADDING_TOP = 8;
@@ -58,12 +59,20 @@ export default function MultipleSelectCheckmarks() {
5859
renderValue={(selected) => selected.join(', ')}
5960
MenuProps={MenuProps}
6061
>
61-
{names.map((name) => (
62-
<MenuItem key={name} value={name}>
63-
<Checkbox checked={personName.includes(name)} />
64-
<ListItemText primary={name} />
65-
</MenuItem>
66-
))}
62+
{names.map((name) => {
63+
const selected = personName.includes(name);
64+
const SelectionIcon = selected ? CheckBoxIcon : CheckBoxOutlineBlankIcon;
65+
66+
return (
67+
<MenuItem key={name} value={name}>
68+
<SelectionIcon
69+
fontSize="small"
70+
style={{ marginRight: 8, padding: 9, boxSizing: 'content-box' }}
71+
/>
72+
<ListItemText primary={name} />
73+
</MenuItem>
74+
);
75+
})}
6776
</Select>
6877
</FormControl>
6978
</div>

0 commit comments

Comments
 (0)