如何使用 Material UI 组件创建项目符号列表?

ast*_*str 18 material-ui

如何使用 MUI 组件创建项目符号列表?我尝试添加sx={{listStyleType:'disc'}}到列表组件,但没有成功。这是我的代码:

    <List sx={{ listStyleType: 'disc' }}>
      <ListSubheader sx={{
        fontWeight: 700, lineHeight: '24px', fontSize: '16px', color: 'black'
      }}
      >
        Search Help
      </ListSubheader>
      <ListItem>Double check your spelling</ListItem>
      <ListItem>Your search may have been removed or is not yet in the system</ListItem>
    </List>
Run Code Online (Sandbox Code Playgroud)

ast*_*str 30

我明白了,需要

<List sx={{ listStyleType: 'disc' }}>
  <ListItem sx={{ display: 'list-item' }}>
</List>
Run Code Online (Sandbox Code Playgroud)

  • 要使此解决方案发挥作用,必须与“&lt;List sx={{ listStyleType: disk', pl: 4 }}&gt;&lt;/List&gt;”结合使用 (12认同)

ata*_*min 6

这对我有用:

<List
sx = {{
 listStyleType: 'disc',
 pl: 2,
 '& .MuiListItem-root': {
  display: 'list-item',
 },
}}>
 <ListItem>
 ...
 </ListItem>
</List>
Run Code Online (Sandbox Code Playgroud)

或者

<List
sx = {{
 listStyleType: 'disc',
 pl: 2,
}}
</List>
<ListItem
sx = {{
 display: 'list-item',
}}>
 ...
</ListItem>
Run Code Online (Sandbox Code Playgroud)