Icons
All system icons are inline SVG files, invoked via a Razor helper. The helper will insert a properly formatted and minified SVG file into your view. All icons are managed and stored within the Icons repository.
Our icons are delivered as a Razor helper in Stack Overflow’s production environment, a custom liquid tag in our documentation’s Eleventy site generator, and a JavaScript helper for use in prototypes.
Helpers should be used for all icons in lieu of SVG sprite sheets or raster image assets. This ensures a single source of truth for all icons.
<!-- Razor -->
@Svg.Logo
<!-- Liquid -->
{% icon "Logo" %}
<!-- JavaScript Helper -->
<svg data-icon="Logo"></svg>
By default, every icon will inherit the text color of its parent. To override this and show the icon with its native colors (Our logos, for example), you can include the native
class in the helper.
<!-- Razor -->
@Svg.Logo.With("native")
<!-- Liquid -->
{% icon "Logo", "native" %}
<!-- JavaScript Helper -->
<svg data-icon="Logo" class="native"></svg>
In fact, our helper supports arbitrary classes as well.
<!-- Razor -->
@Svg.Logo.With("native float-right js-dropdown-target")
<!-- Liquid -->
{% icon "Logo", "native float-right js-dropdown-target" %}
<!-- JavaScript Helper -->
<svg data-icon="Logo" class="native float-right js-dropdown-target"></svg>
If an icon you need isn’t here, please do one of the following two options:
- Submit a request outlining the desired icon, the icon’s intended purposed, and where it will be used.
- If the icon is ready, submit a pull request to have it to be reviewed. Please be sure to provide the same information as above.
If you have further questions, visit the project’s Slack channel: #stacks.