Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
72 lines
1.9 KiB
TypeScript
72 lines
1.9 KiB
TypeScript
import * as React from 'react';
|
|
import OutlinedInput from '@mui/material/OutlinedInput';
|
|
import InputLabel from '@mui/material/InputLabel';
|
|
import MenuItem from '@mui/material/MenuItem';
|
|
import FormControl from '@mui/material/FormControl';
|
|
import ListItemText from '@mui/material/ListItemText';
|
|
import Select, { SelectChangeEvent } from '@mui/material/Select';
|
|
import Checkbox from '@mui/material/Checkbox';
|
|
|
|
const ITEM_HEIGHT = 48;
|
|
const ITEM_PADDING_TOP = 8;
|
|
const MenuProps = {
|
|
PaperProps: {
|
|
style: {
|
|
maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
|
|
width: 250,
|
|
},
|
|
},
|
|
};
|
|
|
|
const names = [
|
|
'Oliver Hansen',
|
|
'Van Henry',
|
|
'April Tucker',
|
|
'Ralph Hubbard',
|
|
'Omar Alexander',
|
|
'Carlos Abbott',
|
|
'Miriam Wagner',
|
|
'Bradley Wilkerson',
|
|
'Virginia Andrews',
|
|
'Kelly Snyder',
|
|
];
|
|
|
|
export default function MultipleSelectCheckmarks() {
|
|
const [personName, setPersonName] = React.useState<string[]>([]);
|
|
|
|
const handleChange = (event: SelectChangeEvent<typeof personName>) => {
|
|
const {
|
|
target: { value },
|
|
} = event;
|
|
setPersonName(
|
|
// On autofill we get a stringified value.
|
|
typeof value === 'string' ? value.split(',') : value,
|
|
);
|
|
};
|
|
|
|
return (
|
|
<div>
|
|
<FormControl sx={{ m: 1, width: 300 }}>
|
|
<InputLabel id="demo-multiple-checkbox-label">Tag</InputLabel>
|
|
<Select
|
|
labelId="demo-multiple-checkbox-label"
|
|
id="demo-multiple-checkbox"
|
|
multiple
|
|
value={personName}
|
|
onChange={handleChange}
|
|
input={<OutlinedInput label="Tag" />}
|
|
renderValue={(selected) => selected.join(', ')}
|
|
MenuProps={MenuProps}
|
|
>
|
|
{names.map((name) => (
|
|
<MenuItem key={name} value={name}>
|
|
<Checkbox checked={personName.includes(name)} />
|
|
<ListItemText primary={name} />
|
|
</MenuItem>
|
|
))}
|
|
</Select>
|
|
</FormControl>
|
|
</div>
|
|
);
|
|
}
|