8000 GitHub - dominicbarnes/buttonset: Component for taking user input on a group of options (think checkboxes or radio buttons) · GitHub
[go: up one dir, main page]

Skip to content
dominicbarnesPublic

About

Component for taking user input on a group of options (think checkboxes or radio buttons)

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

buttonset

Allows a user to have several options they can click to toggle on and off.

$ component install dominicbarnes/buttonset
buttonset("#my-element")
    .multiple()
    .option("a", "Letter A")
    .option("b", "Letter B", { disabled: true }) // disabled on init
    .option("c", "Letter C", { active: true })   // active on init
    .option("d", "Letter D");

API

Buttonset(el) constructor

Initializes a new selection group at the input element. (el can be either an HTMLElement or a CSS selector String)

Buttonset#multiple()

Allows multiple options to be selected (default is to only allow 1 to be active at a time)

Buttonset#option(value, label, [options])

Adds a new option to the menu. value is the actual value of the selection (must be unique to this option) label is the HTML content of the label to be presented to the user.

options is an optional way for you to set the state upon initialization. It is an object with 2 possible keys: disabled and active (each does what you expect)

Buttonset#value([value])

Alias: selected

Retrieves the selected options. By default, it will return a single value. If multiple has been enabled, it will be an Array of values.

If a value is specified, it will act as a setter instead.

Events

  • change: Emitted whenever a option is changed

About

Component for taking user input on a group of options (think checkboxes or radio buttons)

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0