Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Link Purpose Icons

Security covered Under active development 1,087 sites

This project enhances accessibility by automatically adding icons and screen reader hints to links that navigate users to external sites, open in new windows, send emails, download files, initiate calls, or launch third-party applications. It helps users understand link behavior before clicking.

The Link Purpose JS library attaches icons and screen reader hints to links that open external sites, open new windows, send emails, download documents, make calls and open third-party apps.

Accessibility guidelines encourage giving users advance warning if clicking a link causes this type of change of context.

The library includes a default set of icons:

If you want to bring your own icons, the module config page has settings for CSS class-based icon libraries (e.g. Font Awesome Icons). Icons that involve inserting HTML icons, such as inline SVG or Material Icons, can be added by setting a global linkPurposeOptions(options) function in your theme or module JS, and returning a modified options object before it is passed to the library. Check the library examples; the full list of available options is at the bottom of that readme.
 

Features

  1. Icons automatically match link color, even when modified on :hover or :focus, or by system high contrast settings.
  2. The last word of each link is wrapped into a span with the icon, preventing line breaks between the text and the icon.
  3. Links can be excluded by page region or any CSS selector.
  4. Icons and the visually-hidden text for screen readers are in separate containers, allowing designers to remove the icon or the text if context makes one or the other redundant.
  5. For multilingual sites, the visually-hidden text for screen readers passes through Drupal's translation system.
  6. Dynamically inserted (AJAX) links, as well as links inside Shadow DOM / Web Components can be marked as well.

The library accepts numerous parameters for its markup. By default, it will convert this:

<a href="https://example.com">
    EXAMPLE LINK
</a>

to this:

<a href="https://example.com" class="link-purpose link-purpose-external" aria-describedby="link-purpose-description-1">
    EXAMPLE
    <span class="link-purpose-spacer"> </span> 
    <span class="link-purpose-nobreak link-purpose-last-word">
        LINK
        <span class="link-purpose-icon link-purpose-external-icon" aria-hidden="true" title="Link is external">
            <svg ...></svg>
        </span>
        <span class="link-purpose-text" id="link-purpose-description-1">
             Link is external
         </span>
    </span>
</a>

Much of that is helper classes for themers:

  • The link itself receives identifying classes, as well as an aria-describedby connection to descriptive text.
  • A spacer is added before the last word, so it can be sized or hidden.
  • The last word is wrapped in a span with the icon, to allow for fine control of text/icon wrapping.
  • The icon wrapper has its own classes, and a title tag for mouseovers.
  • The descriptive text for screen readers is visually hidden by default, but can be separately targeted by CSS as needed.

 

Post-Installation

It should work out of the box with no configuration overrides at all. If your site has a non-traditional domain configuration, you should set domains you want considered internal in absolute URLs on the configuration page. By default the site's base URL will be used.

The library documentation covers additional options that can be inserted by can be added by setting a global linkPurposeOptions(options) function in your theme or module JS, and returning a modified options object before it is passed to the library.

 

Additional Requirements

None. It's vanilla JS.

 

Editoria11y Accessibility Checker.

 

Similar projects

The External Links module can also mark email and external links. Key differences:

  • The Link Purpose module adds five additional categories (document, telephone, file download, app and new window), allows themes to insert custom link categories, adds line break prevention, and has no jQuery dependency.
  • The External Links module can create "You are leaving the site" popup windows on external links.

The Link Purpose configuration page has instructions for settings that will emulate External Links' markup to assist with migration.

 

Project meta

Drupal 10–11 PHP 8.1

Ask your assistant about Link Purpose Icons

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • user Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
39
Tracked since
Feb 2024
Latest release
5 days ago
Releases (12 mo)
7 ▲ from 5
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
1.1.1 Stable 10–11 PHP 8.1 Nov 24, 2026
1.1.0 Stable 10–11 PHP 8.1 Oct 21, 2026
1.1.x-dev Dev 10–11 PHP 8.1 Oct 21, 2026
1.0.24 Stable 9–11 PHP 8.1 Oct 21, 2026
1.0.23 Stable 9–11 Jul 27, 2026
1.0.22 Stable 9–11 Jul 8, 2026
1.0.21 Stable 9–11 Apr 7, 2026
1.0.20 Stable 9–11 Sep 9, 2025
1.0.19 Stable 9–11 Jul 15, 2025
1.0.18 Stable 9–11 May 28, 2025