Socket
Socket
Sign inDemoInstall

@superherocheesecake/tab-indicator

Package Overview
Dependencies
1
Maintainers
18
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @superherocheesecake/tab-indicator

Observes if a user is using the tab key (to navigate through the site).


Version published
Maintainers
18
Created

Readme

Source

TabIndicator

Observes if a user is using the tab key (to navigate through the site).

Get the package

npm i --save @superherocheesecake/tab-indicator

Import

import TabIndicator from '@superherocheesecake/tab-indicator';

Basic Usage

const tabIndicator = new TabIndicator();

Events

Get Current State
addClassToBody() {
    document.body.classList.add('is-tab-enabled');
}
removeClassFromBody() {
    document.body.classList.remove('is-tab-enabled');
}

// single update event
tabIndicator.addEventListener('update', (isEnabled) => {
    if (isEnabled) {
        addClassToBody();
    }
    else {
        removeClassFromBody();
    }
});

// or listen to separate events
tabIndicator.addEventListener('enabled', () => {
    addClassToBody();
});
tabIndicator.addEventListener('disabled', () => {
    removeClassFromBody();
});

Methods

Get Current State
tabIndicator.isEnabled();

Examples

Example styling for focus (in _base.scss)
:focus {
    outline: highlight solid 2px;
    outline: -webkit-focus-ring-color auto 5px;
}

body:not(.is-tab-enabled) :focus {
    outline: none !important;
}

FAQs

Last updated on 03 Dec 2019

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