[英]How to style MUI TreeItem label?
I'm trying to customize a TreeView
by adding a border to each TreeItem
.我正在尝试通过向每个TreeItem
添加边框来自定义TreeView
。
Generally it works great, my current version looks like this:通常效果很好,我当前的版本如下所示:
But I wish it looks was like that, and I have no idea how to style it:但我希望它看起来像那样,我不知道如何设计它:
So basically, I would like to surround only TreeItem
's label with <div>
.所以基本上,我只想用<div>
包围TreeItem
的标签。 Does anyone have an idea how I can solve this?有谁知道我该如何解决这个问题?
You can target the MuiTreeItem-label
class name when styling the TreeItem
.您可以在MuiTreeItem-label
TreeItem
样式时定位MuiTreeItem-label
类名称。 For reference, see the list of all CSS global class names here .作为参考,请参阅此处的所有 CSS 全局类名称列表。
import TreeItem, { treeItemClasses } from "@mui/lab/TreeItem";
const StyledTreeItem = styled(TreeItem)(({ theme }) => ({
[`& .${treeItemClasses.label}`]: {
border: "solid blue 1px",
borderRadius: theme.shape.borderRadius,
marginTop: 3,
marginBottom: 3
}
}));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.