Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Bootstrap 5 Using the API Enable Responsive

The Bootstrap Utilities are generated with the Bootstrap Utility Api. It can be used to modify or add to the default set of utility classes via Sass.For generating new families of classes with various options it uses Sass maps and functions. The utility API helps to quickly apply styles to HTML elements without writing custom CSS.The $utilities contains all the utilities or the classes that are merged with  $utilities map, if present. The $utilities group accepts some of the options and one such option is responsive.The responsive option of the utilities map takes a boolean as its value, indicating if responsive classes need to be generated or not. It is false by default.Syntax:Example 1: We are customizing the Utility API, we are working on the text-color class by adding some values to it and adding the responsive property to it.style.scssNow we can see that we are able to add the newly generated responsive classes as well like “text-color-sm-red” or “text-color-lg-white”, which will help to provide different text colors for different screen sizes.index.htmlOutput:We can see that for large screen devices the text color is white, then for small devices, it is red.Example 2: In this example, we are customizing the utility API with the height property, we are setting the responsive property as true and adding some values to it.style.scssindex.htmlOutput:Reference: https://getbootstrap.com/docs/5.0/utilities/api/#enable-responsive



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

Bootstrap 5 Using the API Enable Responsive

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×