All icons from the library support being styled by the fill property. You can
change the color of an icon by passing in a custom class name that sets this
property (preferred), or by passing in an inline style. For example:
// CSS custom class name to set the fill of the iconto `rebeccapurple`
svg.my-custom-class {
fill: rebeccapurple;
}
Certain icons in the library support two distinct fill colors. You can target
the inner path by using the [data-icon-path="inner-path"] attribute selector.
For example:
// CSS custom class name to set the fill of the icon to `yellow`svg.my-custom-class {
fill: yellow;
}
// Use the `data-icon-path` attribute selector to target the inner path// where we want to set the fill to `black`. We also set `opacity` to `1` so// that this inner-path is visible.svg.my-custom-class[data-icon-path='inner-path'] {
fill: black;
opacity: 1;
}
By default, the icon components from @carbon/icons-react are treated as
decorative content. This means that we set aria-hidden="true" unless certain
props are passed to the component.
If you would like the icon to be announced by a screen reader, you can supply an
aria-label or aria-labelledby. For example:
Including tabIndex and aria-label (or aria-labelledby) will set the
corresponding tabindex on the underlying <svg> and verify support in older
browsers like Internet Explorer 11 by setting focusable to true.
We're always looking for contributors to help us fix bugs, build new features,
or help us improve the project documentation. If you're interested, definitely
check out our Contributing Guide!
This package uses IBM Telemetry to collect de-identified and anonymized metrics
data. By installing this package as a dependency you are agreeing to telemetry
collection. To opt out, see
Opting out of IBM Telemetry data collection.
For more information on the data being collected, please see the
IBM Telemetry documentation.