Icon
lightning:icon
Represents a visual element that provides context and enhances usability.
For Aura components only. For LWC development, use lightning-formatted-address.
For Use In
Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App, Mobile Offline
A lightning:icon is a visual element that provides context and enhances usability. Icons can be used inside the body of another component or on their own. Specify the icon with the iconName attribute.
Visit https://lightningdesignsystem.com/icons to view the available icons.
When applying Lightning Design System classes or icons, check that they are available in the Lightning Design System release tied to your org. The latest Lightning Design System resources become available only when the new release is available in your org.
Here is an example.
Use the variant, size, or class attributes to customize the styling. The variant attribute changes the appearance of a utility icon. For example, the error variant adds a red fill to the error utility icon. Variants are supported only for utility icons.
If you want to make additional changes to the color or styling of an icon, use the class attribute.
Icons are not available in Lightning Out, but they are available in Lightning Components for Visualforce and other experiences.
When using lightning:icon in a standalone app, extend force:slds to resolve the icon resources correctly.
Use the alternativeText attribute to describe the icon for assistive technology. The description should indicate what happens when you click the button, for example 'Upload File', not what the icon looks like, 'Paperclip'.
Sometimes an icon is decorative and does not need a description. But icons can switch between being decorative or informational based on the screen size. If you choose not to include an alternativeText description, check smaller screens and windows to ensure that the icon is decorative on all formats.
Use the src attribute to specify the path of the resource for the custom icon. When this attribute is present, lightning:icon attempts to load an icon from the provided resource. The iconName attribute is not required when you use a custom icon.
Define a static resource in your org and upload your custom icon's SVG source to it. The SVG must include a <g> element with an ID that you can reference.
For example, suppose your static resource is named mySVG_icon and it contains this google.svg content.
Reference the custom icon using the resource name and the ID assigned to the <g> element.
For IE11, the custom icon feature is disabled for now due to performance issues.
Overriding the Icon Fill Color of Custom Icons
Note that all the icons have a default CSS fill property value ##fff, which you can override in your svg sprite directly. For example, change the color to a shade of green by inserting fill=#648079 in the <svg> element.
You can't use CSS to change the fill color in a custom icon.