在Material UI中为持久抽屉的切换菜单添加文本

huangapple go评论71阅读模式
英文:

Adding text to Toggle Menu of a Persistent Drawer in Material UI

问题

我想在切换抽屉持久存在的按钮所在区域(我已经圈出来了)添加一些文本。这可能吗?如果是的话,我应该如何实现这一点?

在Material UI中为持久抽屉的切换菜单添加文本

我查看了 Stack Overflow 和 Material UI 的文档,似乎没有关于我的问题的答案。

英文:

I would like to add some text in the area (which I've circled) that has the toggle button for persistent drawers. Is this possible? If so, how would I implement this?

在Material UI中为持久抽屉的切换菜单添加文本

I looked through Stack Overflow and Material UI's documentation and there appears to be no answers to this question of mine.

答案1

得分: 0

你可以在DrawerHeader组件中添加任何你想要的文本,就像这样(在这种情况下是"custom header text"):

<DrawerHeader>
  custom header text
  <IconButton onClick={handleDrawerClose}>
    {theme.direction === "ltr" ? (
      <ChevronLeftIcon />
    ) : (
      <ChevronRightIcon />
    )}
  </IconButton>
</DrawerHeader>

你可以在这个沙盒中查看一个实时的工作示例。

英文:

You can add any text you want in DrawerHeader component like this (in this case "custom header text"):

&lt;DrawerHeader&gt;
  custom header text
  &lt;IconButton onClick={handleDrawerClose}&gt;
	{theme.direction === &quot;ltr&quot; ? (
	  &lt;ChevronLeftIcon /&gt;
	) : (
	  &lt;ChevronRightIcon /&gt;
	)}
  &lt;/IconButton&gt;
&lt;/DrawerHeader&gt;

You can take a look at this sandbox for a live working example.

huangapple
  • 本文由 发表于 2023年3月12日 15:52:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75711742.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定