2.2.1 • Published 6 months ago

toggle-targets v2.2.1

Weekly downloads
4
License
ISC
Repository
github
Last release
6 months ago

Toggle Targets

Toggle another element by data attribute.

Demo Examples

Install

npm i toggle-targets

HTML

See examples for .. well, examples. But here's the gist of it, and parameters:

<button
  data-tt-set="example"
  data-tt-toggle="target-1"
>Toggle</button>
<div
  data-tt-set="example"
  data-tt-target="target-1"
  hidden
>
  <p>Target element to be toggled</p>
  <button data-untoggle-set="example">Close</button
</div>

Attributes for the toggle button

AttributeTypeDescription
data-tt-setid (unique)Set of toggles, grouped together
data-tt-toggleid (not unique)ID to toggle, matching the target's data-tt-target

Attributes for the target element

AttributeTypeDescription
data-tt-setid (unique)Set of toggles, grouped together
data-tt-targetid (not unique)ID for this element, matching the toggle's data-tt-toggle
data-tt-blurempty(optional: default false) Hide when clicking anywhere else

Optional additional elements

<button data-tt-untoggle>Close</button
<input data-tt-focus />
AttributeTypeDescription
data-tt-untoggleemptyClose the target element which contains this
data-tt-focusselectorFocus on a selector within

SCSS

@import "toggle-targets/src/index";

JS

import { initToggleTargets } from "toggle-targets";
const toggleSets = initToggleTargets();
2.2.1

6 months ago

2.1.11

9 months ago

1.1.1

3 years ago

1.1.0

3 years ago

2.1.9

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.6

3 years ago

2.1.5

3 years ago

2.1.10

3 years ago

2.1.8

3 years ago

2.1.7

3 years ago

2.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago