March 2019
Intermediate to advanced
534 pages
14h 52m
English
You can mark ListItem components as selected by setting the selected property to true. You can also change the icon to give a better visual indication that an item has been selected. Here's the updated code:
import React, { useState } from 'react';import List from '@material-ui/core/List';import ListItem from '@material-ui/core/ListItem';import ListItemText from '@material-ui/core/ListItemText';import ListItemIcon from '@material-ui/core/ListItemIcon';import AccountCircleIcon from '@material-ui/icons/AccountCircle';import CheckCircleOutlineIcon from '@material-ui/icons/CheckCircleOutline';const MaybeSelectedIcon = ({ selected, Icon }) => selected ? <CheckCircleOutlineIcon /> : <Icon />;export default function ListIcons() { ...Read now
Unlock full access