Europa Component Library

Skip link

Provides a direct link to main content.

Link is only displayed when focused (with keyboard) or to screen readers.

{#
  Accepts:
    - "href" (string): link to jump to (default: '#main-content')
    - "id" (string): ID of the skip link component (default: 'skip-link')
    - "label" (string): link's label (default: 'Skip to main content')
    - "extra_classes" (string): extra CSS classes to be added
    - "extra_attributes" (array): extra attributes classes (optional, format: [{ 'name': 'name_of_the_attribute', 'value': 'value_of_the_attribute'}])
#}

{# Internal properties #}

{% set _href = href|default('#main-content') %}
{% set _id = id|default('skip-link') %}
{% set _label = label|default('Skip to main content') %}
{% set _css_class = 'ecl-skip-link__wrapper' %}
{% set _extra_attributes = '' %}

{# Internal logic - Process properties #}

{% if extra_class is defined %}
  {% set _css_class = _css_class ~ ' ' ~ extra_class %}
{% endif %}

{% if extra_attributes is defined %}
  {% for attr in extra_attributes %}
    {% set _extra_attributes = _extra_attributes ~ ' ' ~ attr.name ~ '="' ~ attr.value ~ '"' %}
  {% endfor %}
{% endif %}

{# Print result #}

<div class="{{ _css_class }}" id="{{ _id }}" {{ _extra_attributes|raw }}>
  <a href="{{ _href }}" class="ecl-skip-link">{{ _label }}</a>
</div>
/* No context defined for this component. */
<div class="ecl-skip-link__wrapper" id="skip-link">
  <a href="#main-content" class="ecl-skip-link">Skip to main content</a>
</div>
  • Content:
    /**
     * Skip link component
     * @define skip-link
     */
    
    .ecl-skip-link__wrapper {
      left: map-get($ecl-spacing, 'l');
      margin: 0;
      position: fixed;
      top: map-get($ecl-spacing, 'l');
      z-index: map-get($ecl-z-index, 'max');
    }
    
    .ecl-skip-link {
      @include ecl-u-sr-only();
      @include ecl-u-sr-only-focusable();
    
      background-color: map-get($ecl-colors, 'blue-75');
      color: #fff;
      outline: 4px solid map-get($ecl-colors, 'yellow-100');
      outline-offset: 0;
      padding: map-get($ecl-spacing, 'xxs');
    
      &:focus,
      &:active {
        white-space: nowrap;
      }
    }
    
  • URL: /components/raw/ecl-skip-links/ecl-skip-links.scss
  • Filesystem Path: framework/components/ecl-skip-links/ecl-skip-links.scss
  • Size: 553 Bytes
  • Handle: @ec-europa/ecl-skip-links
  • Tags: atom
  • Preview:
  • Filesystem Path: framework/components/ecl-skip-links/ecl-skip-links.twig