https://github.com/trychlos/pwix-toggle-switch
A toggle switch Blaze component for Meteor
https://github.com/trychlos/pwix-toggle-switch
meteorjs
Last synced: 5 months ago
JSON representation
A toggle switch Blaze component for Meteor
- Host: GitHub
- URL: https://github.com/trychlos/pwix-toggle-switch
- Owner: trychlos
- Created: 2023-04-28T09:19:41.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2025-07-01T19:08:37.000Z (11 months ago)
- Last Synced: 2025-07-01T20:23:33.879Z (11 months ago)
- Topics: meteorjs
- Language: JavaScript
- Homepage:
- Size: 110 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
Awesome Lists containing this project
README
# 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:
```sh
meteor add pwix:toggle-switch
```
## Usage
Very simple:
### In your HTML template
```html
{{> toggleSwitch (switchParms) }}
```
### In your template helper
```js
switchParms(){
return {
labelLeft: 'my label'
}
}
```
## Provides
### Blaze components
#### `toggleSwitch`
A simple toggle switch:
- an example with a `labelBottom` set, switch is « On »

- an example with a `labelBottom` set, switch is « Off »

- an example with `labelTop` and `labelBottom` set

- an example with `labelLeft` and `labelRight` set

The component is configurable with an object passed as an argument, which may contain:
- `name`
A string which is expected to uniquely identify the toggle switch.
- `labelTop`
- `labelRight`
- `labelBottom`
- `labelLeft`
An HTML string to be displayed above (resp. on the right, below, on the left) of the button, defaulting to none.
- `title`
A string to be used as the button title, defaulting to none.
- `state`
Whether the switch is initially « On », defaulting to `true`.
- `enabled`
Whether the switch is enabled, defaulting to `true`.
#### Informational events
- `ts-answer`
The message is triggered as an answer to `ts-request` received event.
It holds associated `{ name: , state: , enable: }` data.
- `ts-state`
The message is triggered each time the state of the toggle switch changes.
It holds associated `{ name: , state: }` data, where <new_state> is `true` (resp. `false`) when switch is « On » (resp. « Off »).
#### Action events
- `ts-request`
The message can be sent to the `toggleSwitch` component class to request a `ts-answer` answer.
## 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](https://github.com/trychlos/pwix-toggle-switch/issues).
---
P. Wieser
- Last updated on 2025, Jul. 8th