Icon Shortcode

Icon Shortcode

· 2 min read

Overview

The icon shortcode embeds scalable SVG icons from the Ionicons library. It provides optional link wrapping, sizing controls, and full accessibility support with ARIA attributes.

FortyTen loads Ionicons via CDN, so icons render instantly without requiring any additional setup.

Parameters

ParameterTypeRequiredDefaultDescription
namestringYesThe Ionicon name (e.g., “search”, “menu”, “heart”, “star”)
sizestringNoIcon size: “small” or “large”. Omit for default size
linkstringNoURL to wrap the icon in an anchor tag, making it clickable
targetstringNoLink target attribute ("_blank", “_self”, etc.). Only used when link is provided
aria-hiddenstringNoSet to “true” to hide icon from screen readers (for decorative icons)
aria-labelstringNoDescriptive text for screen readers. Required when icon has semantic meaning

Available Icons

Browse the complete list at ionicons.com.

Basic Usage

Simple Icon

Display a single icon by name:

{{< icon name="search" >}}

Icon with Size

Adjust icon size to “small” or “large”:

{{< icon name="menu" size="large" >}}

Make an icon clickable with a URL:

{{< icon name="github" link="https://fortyten.marcelorodrigo.com" >}}

Open link in new tab:

{{< icon name="external-link" target="_blank" link="https://marcelorodrigo.com" >}}

Advanced Examples

Create a row of social icons:

{{< icon name="github" link="https://github.com" aria-label="GitHub" >}}
{{< icon name="twitter" link="https://twitter.com" aria-label="Twitter" >}}
{{< icon name="linkedin" link="https://linkedin.com" aria-label="LinkedIn" >}}

Accessible Icon with Label

Provide context for assistive technologies:

{{< icon name="download" link="/resume.pdf" aria-label="Download my resume" >}}

Decorative Icon

Hide from screen readers when text provides context:

Search {{< icon name="search" aria-hidden="true" >}}

Accessibility Considerations

Screen Reader Support

  1. Semantic Icons — Provide an aria-label:

    {{< icon name="download" aria-label="Download" >}}
    
  2. Decorative Icons — Hide with aria-hidden="true" when text provides context:

    {{< icon name="star" aria-hidden="true" >}} Favorite
    
  3. Icon Links — Always include an accessible label:

    {{< icon name="github" link="https://fortyten.marcelorodrigo.com" aria-label="Visit FortyTen" >}}
    

WCAG Compliance

This shortcode follows WCAG 2.1 Level AA standards with keyboard navigation and screen reader support.

Best Practices

  1. Always add aria-label to linked icons
  2. Use aria-hidden="true" for purely decorative icons

Search pages

Loading search index...

No results found. Try a different search term.

↑↓ navigate Enter select Esc close