Socket
Socket
Sign inDemoInstall

@vue-a11y/skip-to

Package Overview
Dependencies
0
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @vue-a11y/skip-to

It helps people who only use the keyboard to jump to what matters most.


Version published
Weekly downloads
2.4K
increased by1.79%
Maintainers
3
Install size
52.6 kB
Created
Weekly downloads
 

Readme

Source

vue-skip-to

Helps people who only use the keyboard to jump to what matters most

  • Installation
  • Usage
  • Props
  • Custom styling
  • Running tests
  • About
  • Contributing

The population grows very fast nowadays and with that the number of visually impaired increases as well. Did you know that we have over 350 million visually impaired people in the world?

However, we are responsible for doing our utmost to make our applications usable and accessible to everyone.

"Skip to content" or "skip to a section" of your site is one of the most common accessibility techniques today, but not as used as it should be.

This pattern is detailed in the Techniques for WCAG 2.0 in notes G1 and G124, and also served as the inspiration for creating this component.

Check out the live demo!

Installation

// npm
npm install -S @vue-a11y/skip-to

// yarn
yarn add @vue-a11y/skip-to

Usage

Vue SFC

// main.js

import Vue from 'vue'
import VueSkipTo from '@vue-a11y/skip-to'

Vue.use(VueSkipTo)

new Vue({
  //...
})
// App.vue

<template>
  <div id="app">
    <VueSkipTo to="#main" label="Skip to main content" />

    <!-- header, navigation, and more -->

    <main id="main">
      <!-- content -->
    </main>
  </div>
</template>

<script>
export default {
  name: 'app'
  components: {
    Logo,
    VueSkipTo,
  },
  //...
}
</script>
Skip-to list

To use multiple links, set an array into the to prop with the following shape:

[
  {
    "anchor": "<STRING>", // destination id
    "label": "<STRING>" // link text
  }
  //...
]
// App.vue

<template>
  <div id="app">
    <vue-skip-to
      list-label="Skip to"
      :to="[
        { anchor: '#main', label: 'Main content' },
        { anchor: '#footer', label: 'Footer' },
      ]"
    ></vue-skip-to>

    <!-- header, navigation, and more -->

    <main id="main"></div>

    <footer id="footer"></div>
  </div>
</template>

In HTML files

<!--omitted -->
  <script src="https://unpkg.com/vue"></script>
  <script src="https://unpkg.com/@vue-a11y/skip-to"></script>
</head>
<body>
  <div id="app">
    <vue-skip-to to="#main"></vue-skip-to>

    <!-- header, navigation, and more -->

    <main id="main">
      <!-- content -->
    </main>
  </div>

  <script>
    new Vue({
      el: "#app"
    })
  </script>
</body>
</html>

Props

PropData TyperequiredDescriptionDefault
toString | ArrayfalseDestination ID or array of destination objects'#main'
labelStringfalseSkip link text content'Skip to main content'
list-labelStringfalseSkip link list label text'Skip to'

Support route change

@vue-a11y/skip-to checks if you are using the vue-router, watches changes to $route.path and send focus to the vue-skip-to wrapper.

Recommendation: To make more sense, use the VueSkipTo component right after the root element of your app.

Read more about accessible routing:

Custom styling

Override the default styles by targeting the following:

.vue-skip-to {
}
.vue-skip-to__link {
}
.vue-skip-to__nav {
}
.vue-skip-to__nav-list {
}
.vue-skip-to__nav-list-item {
}

Running tests

git clone https://github.com/vue-a11y/vue-skip-to.git
npm install
npm run dev
npm run test:e2e

Or run Cypress on interactive mode

npm run test:e2e:open

About

This component was inspired by this article.

  • This component working in all modern browsers and IE9;
  • Ensures that the target element receives focus, even if it is not a tag that naturally receives focus as the tag input and a. In this case, the div are also given the focus and the tabindex attribute with the value of -1;
  • Add focus to the destination, even when the address bar already has the corresponding hash;

Contributing

  • From typos in documentation to coding new features;
  • Check the open issues or open a new issue to start a discussion around your feature idea or the bug you found;
  • Fork repository, make changes and send a pull request;

Follow us on Twitter @vue_a11y

Thank you

Keywords

FAQs

Last updated on 20 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc