tab-goto
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

jsdelivr npm version codecov

tab-goto

Control where tab or shift+tab goto .

tab-goto

Installation

npm:

npm install tab-goto

Yarn:

yarn add tab-goto

Usage

You can set any CSS Selector to tab-goto or shift-tab-goto attribute to control where tab or shift+tab goto. We use querySelector() internally to find the element to focus.

CDN:

<script src="https://cdn.jsdelivr.net/npm/tab-goto@0.1.0"></script>

<input class="my-input" tab-goto="#my-div" />
<button my-button tab-goto=".my-input" shift-tab-goto='[my-data="div1"]'>
  my button
</button>
<div id="my-div" my-data="div1" tab-goto="[my-button]" tabindex="0">my-div</div>

ESM:

import "tab-goto";

API

config(options)

The config() method is used to configure tab goto uses attribute names and enable/disable tab goto.

Example

CDN:

<input class="my-input" my-tab-goto="#my-div" />
<button my-button my-tab-goto=".my-input" my-shift-tab-goto='[my-data="div1"]'>
  my button
</button>
<div id="my-div" my-data="div1" my-tab-goto="[my-button]" tabindex="0">
  my-div
</div>

<script src="https://cdn.jsdelivr.net/npm/tab-goto@0.1.0"></script>
<script>
  window.tabGoto.config({
    tabGotoName: "my-tab-goto",
    shiftTabGotoName: "my-shift-tab-goto",
    enableTabGoto: true,
    enableShiftTabGoto: true,
  });
</script>

ESM:

import { config as configTabGoto } from "tab-goto";

configTabGoto({
  tabGotoName: "my-tab-goto",
  shiftTabGotoName: "my-shift-tab-goto",
  enableTabGoto: true,
  enableShiftTabGoto: true,
});

Parameters

  • options (Object) - The options object.
    • tabGotoName (string) - The attribute name of tab goto. Default: tab-goto.
    • shiftTabGotoName (string) - The attribute name of shift tab goto. Default: shift-tab-goto.
    • enableTabGoto (boolean) - Whether enable tab goto. Default: true.
    • enableShiftTabGoto (boolean) - Whether enable shift tab goto. Default: true.

Release Notes

Readme

Keywords

none

Package Sidebar

Install

npm i tab-goto

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

13.4 kB

Total Files

27

Last publish

Collaborators

  • zjffun