gpt4 book ai didi

svg - 如何在 material-ui 图标周围添加轮廓/描边?

转载 作者:行者123 更新时间:2023-12-04 01:19:15 27 4
gpt4 key购买 nike

如何在 material-ui 图标周围添加颜色轮廓?
有这个

enter image description here

看起来更像这样?

enter image description here

我尝试过中风和 webkit-stroke,但没有任何运气。它在整个隐形盒子周围放置了一个边框。

最佳答案

在 React 中使用 Material-UI 理论上应该设置属性 strokestroke-width直接到导入的心形图标。但正如你所说,它会在整个 svg 标签周围创建一个尴尬的边框。
然后,您应该能够从 dom 中提取心脏的定义并使用更通用的 SvgIcon Material-UI 提供的组件。

因此,要实现您的目标,而不是:

import { Favorite } from '@material-ui/icons';
export default () => <Favorite stroke={"white"} stroke-width={1}/>

我会去:
import SvgIcon from '@material-ui/core/SvgIcon';
export default () => (
<SvgIcon>
<path
d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"
stroke="white"
strokeWidth={1}
/>
</SvgIcon>
);

关于svg - 如何在 material-ui 图标周围添加轮廓/描边?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53529640/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com