Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
94220f5
chore(deps-dev): bump @rollup/plugin-terser from 0.4.4 to 1.0.0
dependabot[bot] Mar 6, 2026
e993a5a
chore(deps-dev): bump cypress-plugin-tab from 1.0.5 to 2.0.0
dependabot[bot] Mar 6, 2026
dcc736a
ci(deps): bump the minor-and-patch-updates group across 1 directory w…
dependabot[bot] Apr 3, 2026
2101281
Merge pull request #307 from palcarazm/dependabot/github_actions/mino…
palcarazm Apr 3, 2026
9266827
chore: update readme
palcarazm Apr 4, 2026
46759e0
docs: move docs to main branch
palcarazm Apr 4, 2026
01ea971
ci: add dependabot to docs package
palcarazm Apr 4, 2026
a1272c9
chore(deps-dev): bump @types/jquery from 3.5.34 to 4.0.0
dependabot[bot] Apr 4, 2026
9547981
ci: update dependabot config
palcarazm Apr 4, 2026
223a0a6
ci(deps): bump actions/download-artifact from 7 to 8
dependabot[bot] Apr 4, 2026
9cccfae
ci(deps): bump actions/deploy-pages from 4 to 5
dependabot[bot] Apr 4, 2026
aa004a6
ci(deps): bump actions/upload-artifact from 6 to 7
dependabot[bot] Apr 4, 2026
0a58869
ci(deps): bump actions/configure-pages from 5 to 6
dependabot[bot] Apr 4, 2026
6f1f3b0
Merge pull request #312 from palcarazm/dependabot/github_actions/acti…
palcarazm Apr 5, 2026
f093079
Merge pull request #311 from palcarazm/dependabot/github_actions/acti…
palcarazm Apr 5, 2026
e23697f
Merge pull request #310 from palcarazm/dependabot/github_actions/acti…
palcarazm Apr 5, 2026
7ef28e1
Merge pull request #309 from palcarazm/dependabot/github_actions/acti…
palcarazm Apr 5, 2026
3c5b428
Merge pull request #305 from palcarazm/dependabot/npm_and_yarn/cypres…
palcarazm Apr 5, 2026
9ac19e8
Merge pull request #304 from palcarazm/dependabot/npm_and_yarn/rollup…
palcarazm Apr 5, 2026
8e8d190
Merge pull request #303 from palcarazm/dependabot/npm_and_yarn/types/…
palcarazm Apr 5, 2026
1480b7b
chore(docs): upgrade bs-darkmode-toggle to stable and switch to local…
palcarazm Apr 7, 2026
d9b6318
chore(deps-dev): bump typescript from 5.9.3 to 6.0.2 (#306)
dependabot[bot] Apr 7, 2026
e0e127a
Merge branch 'v5' into develop/5.4.0
palcarazm Apr 9, 2026
0b1424e
chore(docs): bump bootstrap5-toggle
dependabot[bot] Apr 10, 2026
1256068
ci(deps): bump actions/upload-pages-artifact from 4 to 5
dependabot[bot] Apr 17, 2026
bc88900
Merge pull request #316 from palcarazm/dependabot/npm_and_yarn/docs/v…
palcarazm Apr 25, 2026
c0b7b0f
Merge pull request #319 from palcarazm/dependabot/github_actions/acti…
palcarazm Apr 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ updates:
prefix: "chore(deps): "
prefix-development: "chore(deps-dev): "

# ========== DOCS DEPENDENCIES ==========
- package-ecosystem: "npm"
directory: "/docs"
schedule:
interval: "weekly"
day: "friday"
groups:
version-updates:
applies-to: "version-updates"
update-types: ["major", "minor", "patch"]
commit-message:
prefix: "chore(docs): "
prefix-development: "chore(docs): "

# ========== GITHUB ACTIONS ==========
- package-ecosystem: "github-actions"
directory: "/"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: npm run test:unit
- name: Upload coverage report to Github
if: always()
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v7
with:
name: coverage-report-${{ matrix.node-version }}
path: coverage
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
run: npm run build
- name: Cypress run
#v6.10.8
uses: cypress-io/github-action@84d178e4bbce871e23f2ffa3085898cde0e4f0ec
uses: cypress-io/github-action@783cb3f07983868532cabaedaa1e6c00ff4786a8
with:
browser: chrome

Expand Down Expand Up @@ -112,13 +112,13 @@ jobs:
fetch-depth: 0

- name: Download coverage artifact
uses: actions/download-artifact@v7
uses: actions/download-artifact@v8
with:
name: coverage-report-22.x
path: coverage

- name: SonarQube Scan
# v7.0.0
uses: SonarSource/sonarqube-scan-action@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9
uses: SonarSource/sonarqube-scan-action@299e4b793aaa83bf2aba7c9c14bedbb485688ec4
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
15 changes: 9 additions & 6 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Deploy documentation

on:
push:
branches: [ "gh-pages" ]
branches: [ "v5" ]
pull_request:
branches: [ "gh-pages" ]
branches: [ "v5" ]
workflow_dispatch:

permissions:
Expand All @@ -19,6 +19,9 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs
steps:
- name: Checkout
uses: actions/checkout@v6
Expand All @@ -31,11 +34,11 @@ jobs:
- name: Build
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v5
uses: actions/configure-pages@v6
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
uses: actions/upload-pages-artifact@v5
with:
path: './dist'
path: ./docs/dist
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v5
36 changes: 26 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
.DS_Store
# Node modules
node_modules
package-lock.json

# Packaging
bootstrap5-toggle-*.tgz

# Debug
debug

# Dist
js
!src/main/js
!docs/src/js
css
!docs/src/css
dist
@types

# Logs
*.log
bootstrap*.tgz
cypress/videos
cypress/screenshots
cypress/downloads

# Cache and config dirs and files
.vscode
.dccache
js
css
debug
.DS_Store

# Test
coverage
dist
@types
cypress/videos
cypress/screenshots
cypress/downloads
32 changes: 24 additions & 8 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
.DS_Store
# Node modules
node_modules
*.log

# Packaging
bootstrap5-toggle-*.tgz

# Debug
debug
img

# Docs
docs

# Logs
*.log

# Cache and config dirs and files
.github
.vscode
.prettierrc
.dccache
test
bootstrap*.tgz
cypress
.DS_Store
.prettierrc

# Cypress and testing
test/*
cypress/*
cypress.config.js
README.template.md
coverage

# Templates
*.template*
159 changes: 4 additions & 155 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

See EOL for each version in [Security Policy Page](https://github.com/palcarazm/bootstrap5-toggle/security/policy).

# Demos
# Demo and documentation

**Demos and API Docs:** https://palcarazm.github.io/bootstrap5-toggle/
**Please read our documentation page for a completed usage explanation:** https://palcarazm.github.io/bootstrap5-toggle/

---

Expand All @@ -50,14 +50,7 @@ See EOL for each version in [Security Policy Page](https://github.com/palcarazm/
- [Usage](#usage)
- [Initialize With HTML](#initialize-with-html)
- [Initialize With Code](#initialize-with-code)
- [API](#api)
- [Options](#options)
- [Methods](#methods)
- [Events](#events)
- [Event Propagation](#event-propagation)
- [Stopping Event Propagation](#stopping-event-propagation)
- [API vs Input](#api-vs-input)
- [Collaborators welcom!](#collaborators-welcom)
- [Collaborators welcome!](#collaborators-welcome)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -128,151 +121,7 @@ EX: Initialize id `chkToggle` with a single line of JavaScript.
</script>
```

# API

## Options

- Options can be passed via data attributes or JavaScript
- For data attributes, append the option name to `data-` (ex: `data-on="Enabled"`)

```html
<input
type="checkbox"
data-toggle="toggle"
data-onlabel="Enabled"
data-offlabel="Disabled" />
<input type="checkbox" id="toggle-two" />
<script>
document.querySelector("#toggle-two").bootstrapToggle({
on: "Enabled",
off: "Disabled",
});
</script>
```

| Name | Type | Default | Description |
| ---------- | ----------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `onlabel` | string/html | "On" | Text of the on toggle |
| `offlabel` | string/html | "Off" | Text of the off toggle |
| `size` | string | "normal" | Size of the toggle. Possible values are: `large`, `normal`, `small`, `mini`. |
| `onstyle` | string | "primary" | Style of the on toggle. Possible values are: `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, `dark` and with `outline-` prefix |
| `offstyle` | string | "secondary" | Style of the off toggle. Possible values are: `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, `dark` and with `outline-` prefix |
| `onvalue` | string | _null_ | Sets on state value |
| `offvalue` | string | _null_ | Sets off state value |
| `ontitle` | string | _null_ | Title of the on toggle |
| `offtitle` | string | _null_ | Title of the off toggle |
| `style` | string | | Appends the value to the class attribute of the toggle. This can be used to apply custom styles. Refer to Custom Styles for reference. |
| `width` | integer | _null_ | Sets the width of the toggle. if set to _null_, width will be auto-calculated. |
| `height` | integer | _null_ | Sets the height of the toggle. if set to _null_, height will be auto-calculated. |
| `tabindex` | integer | 0 | Sets the tabindex of the toggle. |
| `tristate` | boolean | false | Sets tristate support |

## Methods

Methods can be used to control toggles directly.

```html
<input id="toggle-demo" type="checkbox" data-toggle="toggle" />
<script>
const toggleDemo = document.querySelector("#toggle-demo");
</script>
```

| Method | Example | Description |
| ------------- | --------------------------------------------- | ------------------------------------------------------------------------------------- |
| initialize | `toggleDemo.bootstrapToggle()` | Initializes the toggle plugin with options |
| destroy | `toggleDemo.bootstrapToggle('destroy')` | Destroys the toggle |
| rerender | `toggleDemo.bootstrapToggle('rerender')` | Rerender toggle with the appropriated size. Useful when parent is collapsed at first. |
| on | `toggleDemo.bootstrapToggle('on')` | Sets the toggle to 'On' state |
| off | `toggleDemo.bootstrapToggle('off')` | Sets the toggle to 'Off' state |
| toggle | `toggleDemo.bootstrapToggle('toggle')` | Toggles the state of the toggle on/off |
| enable | `toggleDemo.bootstrapToggle('enable')` | Enables the toggle |
| disable | `toggleDemo.bootstrapToggle('disable')` | Disables the toggle |
| readonly | `toggleDemo.bootstrapToggle('readonly')` | Disables the toggle but preserve checkbox enabled |
| indeterminate | `toggleDemo.bootstrapToggle('indeterminate')` | Sets the toggle to 'indeterminate' state |
| determinate | `toggleDemo.bootstrapToggle('determinate')` | Sets the toggle to 'determinate' state |

# Events

## Event Propagation

Note All events are propagated to and from input element to the toggle.

You should listen to events from the `<input type="checkbox">` directly rather than look for custom events.

```html
<input id="toggle-event" type="checkbox" data-toggle="toggle" />
<div id="console-event"></div>
<script>
document.querySelector("#toggle-event").change(function (e) {
document
.querySelector("#console-event")
.html("Toggle: " + e.target.prop("checked"));
});
</script>
```

## Stopping Event Propagation

Passing `true` to the on, off, toggle, determinate and indeterminate methods will enable the silent option to prevent the control from propagating the change event in cases where you want to update the controls on/off state, but do not want to fire the onChange event.

```html
<input id="toggle-silent" type="checkbox" data-toggle="toggle" />
<button class="btn btn-success" onclick="toggleApiOnSilent()">
On by API (silent)
</button>
<button class="btn btn-success" onclick="toggleApiOffSilent()">
Off by API (silent)
</button>
<button class="btn btn-warning" onclick="toggleApiOnNotSilent()">
On by API (not silent)
</button>
<button class="btn btn-warning" onclick="toggleApiOffNotSilent()">
On by API (not silent)
</button>
<script>
function toggleApiOnSilent() {
document.querySelector("#toggle-silent").bootstrapToggle("on", true);
}
function toggleApiOffSilent() {
document.querySelector("#toggle-silent").bootstrapToggle("off", true);
}
function toggleApiOnNotSilent() {
document.querySelector("#toggle-silent").bootstrapToggle("on");
}
function toggleApiOffNotSilent() {
document.querySelector("#toggle-silent").bootstrapToggle("off");
}
</script>
```

## API vs Input

This also means that using the API or Input to trigger events will work both ways.

```html
<input id="toggle-trigger" type="checkbox" data-toggle="toggle" />
<button class="btn btn-success" onclick="toggleApiOn()">On by API</button>
<button class="btn btn-danger" onclick="toggleApiOff()">Off by API</button>
<button class="btn btn-success" onclick="toggleInpOn()">On by Input</button>
<button class="btn btn-danger" onclick="toggleInpOff()">Off by Input</button>
<script>
function toggleApiOn() {
document.querySelector("#toggle-trigger").bootstrapToggle("on");
}
function toggleApiOff() {
document.querySelector("#toggle-trigger").bootstrapToggle("off");
}
function toggleInpOn() {
document.querySelector("#toggle-trigger").prop("checked", true).change();
}
function toggleInpOff() {
document.querySelector("#toggle-trigger").prop("checked", false).change();
}
</script>
```

# Collaborators welcom!
# Collaborators welcome!

- :sos: Do you need some help? Open a thread in [GitHub Discussions Q&A](https://github.com/palcarazm/bootstrap5-toggle/discussions/new?category=q-a)
- :bug: Do you find a bug? Open an issue in [GitHub bug report](https://github.com/palcarazm/bootstrap5-toggle/issues/new?template=01-BUG_REPORT.yml)
Expand Down
Loading
Loading