Skip to content

Commit 2ef3489

Browse files
authored
feat(icons): add currentColor example (#3007)
1 parent 1c5b024 commit 2ef3489

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

ui/components/icons/_doc.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
* - [Standard](/components/icons?variant=standard) and [Custom](/components/icons?variant=custom) icons have a rounded square shape and use a class on the container for the background color.
5050
* - [Utility](/components/icons?variant=base) icons have no background color.
5151
*
52+
* #### Changing the fill of an icon using currentColor
53+
*
54+
* To change the fill of an icon to match the current color of it's parent, add the `slds-current-color` class to the icon's container. This class utilizes the css currentColor value.
55+
*
5256
* #### Accessibility
5357
*
5458
* Icons require a `span` with the `.slds-icon_container` class. This contains

ui/components/icons/base/_index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ $bg-standard-map: map-merge($task2-monkey-patch, $bg-standard-map);
181181
/**
182182
* @selector .slds-current-color
183183
* @restrict *
184+
* @modifier
185+
* @group color
184186
*/
185187
.slds-current-color {
186188

ui/components/icons/base/example.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export let UtilityIcon = props => {
1414
props.containerClassName
1515
)}
1616
title={
17-
props.title !== false ? (
18-
props.title || 'Description of icon when needed'
19-
) : null
17+
props.title !== false
18+
? props.title || 'Description of icon when needed'
19+
: null
2020
}
2121
>
2222
<SvgIcon
@@ -38,3 +38,11 @@ export let UtilityIcon = props => {
3838
/// ///////////////////////////////////////////
3939

4040
export default <UtilityIcon className="slds-icon-text-default" />;
41+
42+
export let examples = [
43+
{
44+
id: 'currentColor',
45+
label: 'Current Color',
46+
element: <UtilityIcon containerClassName="slds-current-color" />
47+
}
48+
];

0 commit comments

Comments
 (0)