Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many data attributes there are in Bootstrap? What they do and what are the possible values for them? [closed]

I've been searching the web about the data attributes in bootstrap, like data-toggle, data-trigger, data-ride.... but I can't seem to find a list about all of them.

I'm also wondering what are the possible values for them, for example: data-trigger="focus". Instead of focus, it could be hover, and many others. Where can I find a list about all of them? Thanks!

like image 686
user3658801 Avatar asked Jul 12 '16 18:07

user3658801


People also ask

What are the different attributes of data in HTML?

HTML | data-* Attributes It is used to store custom data in private to the page or application. There are mainly 2 parts of the Data Attributes: Attribute Name: Must be at least one character long, contain no capital letters and be prefixed with 'data-'. Attribute Value: Can be any string.

What is data toggle attribute in bootstrap?

The data-toggle is an HTML-5 data attribute defined in Bootstrap. The advantage of using this is that, you can select a class or an id and hook up the element with a particular widget.

What are data attributes good for HTML?

data-* attributes allow us to store extra information on standard, semantic HTML elements without other hacks such as non-standard attributes, or extra properties on DOM.

What is data toggle and data target in bootstrap?

The toggle tells Bootstrap what to do and the target tells Bootstrap which element is going to open. So whenever a link like that is clicked, a modal with an id of “basicModal” will appear.


1 Answers

This is the complete reference of data attributes for bootstrap 3

The reference is based on the data exists in the bootstrap 3 manual page, divided by the different modules.

Modals

data-toggle="modal" - Triggers click to open a modal dialog referenced by data-target="element" data-target="target-element" - The element that the modal should open (can be #id or .class)
data-dismiss="modal" - Triggers close of the modal on click

Dropdowns

data-toggle="dropdown" - Triggers click to open a drop-down
data-target="#" - Only exists to help when use the dropdown on link to prevent url change

ScrollSpy

data-spy="scroll" - Triggers the SpyScroll on the element (usually goes to <body>
data-target="target-element" - The element that the scroll-spy should by applied to
data-offset="X" - X represents the number of pixels from top when calculating position of scroll

Togglable tabs

data-toggle="tab" - Triggers click to open the relevant tab referenced by data-target="element"
data-toggle="pill" - Same as tab but for pill-styling
data-target="target-element" - The element that the modal should open (can be #id or .class)

Note that it's also possible to use href="#target-element-id" and not only data-target here

Tooltips

data-toggle="tooltip" - Triggers adding a tooltip to the element

The tooltip has many data attributes, so this is only the list of all of them with the available values. Complete explanation of all of them is in this link.

data-animation
data-container
data-delay
data-html
data-placement
data-selector
data-template
data-title
data-trigger
data-viewport

Popovers

data-toggle="popover" - Triggers click to open a popover

The popovers has many data attributes, so this is only the list of all of them with the available values. Complete explanation of all of them is in this link.

data-animation
data-container
data-content
data-delay
data-html
data-placement
data-selector
data-template
data-title
data-trigger
data-viewport

Alert messages

data-dismiss="alert" - Triggers click to close the alert box created by bootstrap

Buttons

data-loading-text="Loading..." - Show a text while loading (note that it's deprecated)
data-toggle="button" - note the singular Makes a button single toggle-button data-toggle="buttons" - note the plural Makes a group of buttons a toggle-buttons
data-complete-text="Finished" - Text to change on button when the method complete is called

Collapse

data-toggle="collapse" - Triggers click to collapse the referenced element
data-target="element" - The referenced element
data-parent="element" - The parent element, used for accordion-style collapsing

Carousel

data-ride="carousel" - Triggers a slide-show (carousel) on the container
data-target="element" - The referenced carousel element that this element is part of
data-slide-to="X" - X is the number of the next slide
data-slide="prev|next" - Triggers click to toggle the carousel to the prev|next slide
data-interval="X" - The amount of time to delay between automatically cycling an item
data-pause="hover" - Pause the cycling on mouse over
data-wrap="true" - Whether the carousel should cycle continuously or have hard stops
data-keyboard="true" - Whether the carousel should react to keyboard events

Affix

data-spy="affix" - Triggers affix (emulating the sticky positioning effect)
data-offset-top="X" - Number of pixels to offset the element from top
data-offset-bottom="X" - Number of pixels to offset the element from bottom

like image 102
Dekel Avatar answered Oct 21 '22 11:10

Dekel