Skip to content

Commit e698eef

Browse files
committed
updated “Color” section in “How to use” for Hds::Icon
1 parent 567623e commit e698eef

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

website/docs/components/icon/partials/code/how-to-use.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,21 @@ The default size is 16px. To use the alternative 24px icon size, set the `@size`
3636

3737
### Color
3838

39-
The default value is `currentColor` which uses the inherited text color as the icon color. When setting a custom value, we recommend using one of the pre-defined variables to ensure consistency with our design language:
39+
The default value is `currentColor` which uses the inherited text color as the icon color. When setting a custom value, we recommend using one of the pre-defined **foreground** color variables to ensure consistency with our design language:
4040

4141
```handlebars
42-
<Hds::Icon @name="zap" @color="var(--token-color-foreground-success)" />
42+
<Hds::Icon @name="zap" @color="success" />
4343
```
4444

45-
Other accepted values include named colors and color values themselves (e.g., hex, rgb, etc).
45+
For the list of possible foreground colors supported, refer to the [Component API](#component-api) section for details.
46+
47+
It’s also possible to provide a CSS color as string (in this case the color will be applied as SVG `fill` property). The string can be a CSS `var()` that uses one of the [predefined color tokens](/foundations/colors?tab=palette):
48+
49+
```handlebars
50+
<Hds::Icon @name="zap" @color="var(--token-color-boundary-brand)" />
51+
```
52+
53+
Or it can be one of the standard CSS color formats (hex, rgb, rgba, hsl, named color, etc.):
4654

4755
```handlebars
4856
<Hds::Icon @name="zap" @color="rebeccapurple" />
@@ -52,6 +60,12 @@ Other accepted values include named colors and color values themselves (e.g., he
5260
<Hds::Icon @name="zap" @color="rgb(46, 113, 229)" />
5361
```
5462

63+
!!! Warning
64+
65+
We don’t validate the CSS color string to ensure that the value used is correct.
66+
67+
!!!
68+
5569
### Stretched
5670

5771
To have the icon fill the parent container (width: 100%, height: 100%), set the `@stretched` attribute to true:

0 commit comments

Comments
 (0)