Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To incorporate an icon into MobileDatePicker in MUI v5, you can use the InputProps property and pass an endAdornment prop with the icon component.

import { MobileDatePicker, InputAdornment, IconButton } from "@mui/lab";
import EventIcon from "@mui/icons-material/Event";

<MobileDatePicker
    label="Date"
    value={selectedDate}
    onChange={handleDateChange}
    renderInput={(params) => (
        <TextField
            {...params}
            InputProps={{
                endAdornment: (
                    <InputAdornment position="end">
                        <IconButton>
                            <EventIcon />
                        </IconButton>
                    </InputAdornment>
                ),
            }}
        />
    )}
/>

In the example above, we import the IconButton component from MUI and the EventIcon from the Material Icons library. We then pass this icon component to the InputAdornment component, which we pass to the endAdornment prop of InputProps within the renderInput prop of MobileDatePicker.