Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Bootstrap data-toggle vs data-bs-toggle attributes?

Context

I am using a Bootstrap theme, and now I noticed, when the theme updated to Bootstrap 5 all data-toggle attributes were replaced with data-bs-toggle (except one, which element still works btw).

Question

What is the difference between Bootstrap's data-toggle vs data-bs-toggle attributes?

like image 954
g.pickardou Avatar asked Sep 02 '25 04:09

g.pickardou


1 Answers

This comes fro PR 31827 and commit 418f17e (Nov. 2020, bootstrap v5.0.0-beta1)

It fixes issue 29479 "Add a namespace for data-* attribute?"

As explained in "What’s New in Bootstrap 5 / Change in data attributes" from Shahed Nasser:

Bootstrap 5 has changed the naming of the data attributes that are generally used by its components that use JavaScript as part of their functionality.

Previously, most components that relied on some JavaScript functionalities would have data attributes starting with data-.

In Bootstrap 5, data attributes for these components now start with data-bs to easily namespace Bootstrap attributes.

Commit b38110a concurs:

Data attributes for all JavaScript plugins are now namespaced to help distinguish Bootstrap functionality from third parties and your own code.
For example, we use data-bs-toggle instead of data-toggle.

like image 58
VonC Avatar answered Sep 05 '25 02:09

VonC