Skip to content

颜色

🌐 Color

默认情况下,所有图标的颜色值为:currentColor。此关键字使用元素计算得到的文本 color 值来表示图标颜色。

🌐 By default, all icons have the color value: currentColor. This keyword uses the element's computed text color value to represent the icon color.

在 MDN 上阅读更多关于 currentColor 的内容。

🌐 Read more about currentColor on MDN.

使用 color 属性调整颜色

🌐 Adjust the color using the color prop

可以通过将 color 属性传递给元素来调整颜色。

🌐 The color can be adjusted by passing the color prop to the element.

<script>
import Smile from '@lucide/svelte/icons/smile';
</script>

<Smile color="#3e9392" />

使用父元素文本颜色值

🌐 Using parent elements text color value

由于 lucide 图标的颜色使用 currentColor,图标的颜色取决于元素的计算 color,或者它从其父元素继承。

🌐 Because the color of lucide icons uses currentColor, the color of the icon depends on the computed color of the element, or it inherits it from its parent.

例如,如果父元素的颜色值是 #fff,而其中一个子元素是 lucide 图标,该图标的颜色将显示为 #fff。这是浏览器的原生行为。

🌐 For example, if a parent element's color value is #fff and one of the children is a lucide icon, the color of the icon will be rendered as #fff. This is browser native behavior.

<script>
import ThumbsUp from "@lucide/svelte/icons/thumbs-up";
</script>

<button style:color="#fff">
  <ThumbsUp />
  Like
</button>