pwix:toggle-switch
What is it ?
A simple toggle switch Blaze component for Meteor.
Why this package?
Well because we cannot just copy a Blaze component in each and every package or application which would need it:
- first, because this is always a bad idea to just duplicate code, as this obviously also duplicates maintenance efforts and bugs
- second, because Blaze has a single namespace per application, and so refuses to have a duplicated component name.
Installation
This Meteor package is installable with the usual command:
meteor add pwix:toggle-switch
Usage
Very simple:
In your HTML template
1 {{> toggleSwitch (switchParms) }}
In your template helper
1 switchParms(){ 2 return { 3 labelLeft: 'my label' 4 } 5 }
Provides
Blaze components
toggleSwitch
A simple toggle switch:
-
an example with a
labelBottomset, switch is « On »
-
an example with a
labelBottomset, switch is « Off »
-
an example with
labelTopandlabelBottomset
-
an example with
labelLeftandlabelRightset
The component is configurable with an object passed as an argument, which may contain:
-
nameA string which is expected to uniquely identify the toggle switch.
-
labelTop -
labelRight -
labelBottom -
labelLeftAn HTML string to be displayed above (resp. on the right, below, on the left) of the button, defaulting to none.
-
titleA string to be used as the button title, defaulting to none.
-
stateWhether the switch is initially « On », defaulting to
true. -
enabledWhether the switch is enabled, defaulting to
true.
Informational events
-
ts-answerThe message is triggered as an answer to
ts-requestreceived event.It holds associated
{ name: <name>, state: <state>, enable: <enabled> }data. -
ts-stateThe message is triggered each time the state of the toggle switch changes.
It holds associated
{ name: <name>, state: <new_state> }data, where <new_state> istrue(resp.false) when switch is « On » (resp. « Off »).
Action events
-
ts-requestThe message can be sent to the
toggleSwitchcomponent class to request ats-answeranswer.
Configuration
None at the moment.
NPM peer dependencies
None at the moment.
Translations
None at the moment.
Cookies and comparable technologies
None at the moment.
Issues & help
In case of support or error, please report your issue request to our Issues tracker.
P. Wieser
- Last updated on 2025, Jul. 8th