Giter Site home page Giter Site logo

doc22940 / skip-navigation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andreasbm/skip-navigation

1.0 1.0 0.0 540 KB

Web component friendly skip navigation functionality

Home Page: https://appnest-demo.firebaseapp.com/skip-navigation/

License: MIT License

JavaScript 2.46% TypeScript 57.80% HTML 32.86% CSS 6.88%

skip-navigation's Introduction

@a11y/skip-navigation

Downloads per month NPM Version Dependencies Contributors

Web component friendly skip navigation functionality.
Go here to see a demo https://appnest-demo.firebaseapp.com/skip-navigation/.


-----------------------------------------------------

➤ Installation

$ npm i @a11y/skip-navigation

-----------------------------------------------------

➤ Usage

Here's an example on how to use this library. After you have imported it you can use the <skip-button> and <skip-anchor tags. The skip-button element presents a skip button to the user when it is focused. The skip-anchor element defines where to the focus should be set when the skip button is used.

<!DOCTYPE html>
<html>
  <body>
    <skip-button></skip-button>
    <a href="#">Irrelevant link 1</a>
    <a href="#">Irrelevant link 2</a>

    <!-- More irrelevant links.. -->

    <skip-anchor></skip-anchor>

    <!-- Main content -->
  </body>
</html>

If you want to have multiple skip-button elements you can set an id on the skip-anchor and use the for attribute on the skip-button like this.

<!DOCTYPE html>
<html>
  <body>

    <!-- When this skip button is pressed the focus is shifted to the anchor with the maincontent ID -->
    <skip-button for="maincontent">Skip to main content</skip-button>
    <skip-anchor id="navigation"></skip-anchor>

    <a href="#">Irrelevant link 1</a>
    <a href="#">Irrelevant link 2</a>

    <!-- More irrelevant links.. -->

    <skip-anchor id="maincontent"></skip-anchor>

    <!-- Main content -->

    <!-- When this skip button is pressed the focus is shifted to the anchor with the navigation ID -->
    <skip-button for="navigation">Skip to navigation</skip-button>
  </body>
</html>

-----------------------------------------------------

➤ Documentation

This section documents the attributes, css variables and slots of the web components this library exposes.

-----------------------------------------------------

➤ skip-button

Button that skips to an anchor.

Attributes

Attribute Type Description
for string Optional ID of the anchor that should be navigated to.

CSS Custom Properties

Property Description
--skip-button-bg Background.
--skip-button-border-radius Border radius.
--skip-button-color Foreground.
--skip-button-font-size Font size.
--skip-button-padding Padding.
--skip-button-transition Transition.

Slots

Name Description
Text to the user. Defaults to "Skip to main content"

-----------------------------------------------------

➤ skip-anchor

Anchor that the skip button can skip to.

Attributes

Attribute Type Description
id string Optional ID that should be associated with the anchor when using the skip-button for attribute.

-----------------------------------------------------

➤ Motivation

Without being able to bypass long lists of links, some users are at a huge disadvantage. A user should never be required to perform any action perhaps 200s of times before reaching the main content. Sighted users have a built-in "skip navigation" mechanism: their eyes so why not give one to keyboard users? A "skip navigation" link is a link at the top of the page which jumps the user down to an anchor or target at the beginning of the main content. The most accessible method for visually hiding "skip navigation" links is to hide them off screen, then cause them to be positioned on screen when they receive keyboard focus.

Read more here if you are interested in learning more.

-----------------------------------------------------

➤ Contributors

Andreas Mehlsen You?
Andreas Mehlsen You?

-----------------------------------------------------

➤ License

Licensed under MIT.

skip-navigation's People

Contributors

andreasbm avatar

Stargazers

Acampbell avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.