Looking for assistance in creating Bootstrap 5 utility classes

I'm currently tasked with setting up utility classes for a company that wishes to create their own. Here are some key details:

  • The imports listed are already in use by the company, and I have added code to generate classes like test-25, which is not working as expected.
  • The CSS compiles without errors, but my utility code is not showing up in the final output.
  • To test if the SASS import is working correctly, I added styles such as { background: red } which worked, but the utility class below was not included in the compiled CSS.

Here is the code I am working with:

// Bootstrap SCSS

// 1. Include functions first (so you can manipulate colors, SVGs, calc, etc)
@import 'bootstrap/scss/functions';

// 2. Include remainder of required Bootstrap stylesheets
@import './variables';

// 3. Include any default variable overrides here
@import '../custom';

// 4. Include any default map overrides here

// 5. Include remainder of required parts
@import 'bootstrap/scss/maps';
@import 'bootstrap/scss/mixins';
@import 'bootstrap/scss/root';

// 5. Custom mixins
@import './mixins/forms';

// 6. Optionally include any other parts as needed
@import 'bootstrap/scss/utilities';
@import './reboot'; // evi
@import 'bootstrap/scss/type';
@import 'bootstrap/scss/images';
@import 'bootstrap/scss/containers';
@import 'bootstrap/scss/grid';
@import 'bootstrap/scss/tables';
@import 'bootstrap/scss/forms/floating-labels';
@import 'bootstrap/scss/forms/form-check';
@import 'bootstrap/scss/forms/form-control';
@import './forms/form-range'; // evi
@import 'bootstrap/scss/forms/form-select';
@import 'bootstrap/scss/forms/form-text';
@import 'bootstrap/scss/forms/input-group';
@import 'bootstrap/scss/forms/labels';
@import 'bootstrap/scss/forms/validation';
@import 'bootstrap/scss/buttons';
@import 'bootstrap/scss/transitions';
@import 'bootstrap/scss/dropdown';
@import 'bootstrap/scss/button-group';
@import 'bootstrap/scss/nav';
@import 'bootstrap/scss/navbar';
@import 'bootstrap/scss/card';
@import 'bootstrap/scss/accordion';
@import 'bootstrap/scss/breadcrumb';
@import 'bootstrap/scss/pagination';
@import 'bootstrap/scss/badge';
@import 'bootstrap/scss/alert';
@import 'bootstrap/scss/progress';
@import 'bootstrap/scss/list-group';
@import 'bootstrap/scss/close';
@import 'bootstrap/scss/toasts';
@import 'bootstrap/scss/modal';
@import 'bootstrap/scss/tooltip';
@import 'bootstrap/scss/popover';
@import 'bootstrap/scss/carousel';
@import 'bootstrap/scss/spinners';
@import 'bootstrap/scss/offcanvas';
@import 'bootstrap/scss/placeholders';
@import 'bootstrap/scss/helpers';

// my code: 

$utilities: map-merge(
    $utilities, (
    "test": (
      property: opacity,
      values: (
        0: 0,
        25:.25,
        50:.5,
        75:.75,
        100: 1,
      )
    )
  )
);



// 7. Optionally include utilities API last to generate classes based on the Sass map in `_utilities.scss`
@import 'bootstrap/scss/utilities/api';

Answer №1

The _utilities.scss provides a vast array of examples that are available for copying and pasting. Upon reviewing these, I discovered the necessity of including the class attribute for proper functionality:

Here is an updated version of my code that now functions correctly:

$newUtilities: map-merge(
    $utilities, (
    "sample": (
      property: opacity,
      class: sample,
      values: (
        0: 0,
        25:.25,
        50:.5,
        75:.75,
        100: 1,
      )
    )
  )
);

$utilities: map-merge($utilities, $newUtilities);

As a result, classes like sample-25 now operate as expected.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Generate a vertical line that spans the entire length of the webpage in a vertical direction

Looking for a way to add vertical borders that span the entire webpage to some text? Check out this HTML snippet: <div id="vLine"> <h1>text</h1> </div> Here's the accompanying CSS: #vLine { height: 100%; width: 5 ...

Arranging Bootstrap Grids within Laravel

On my current web page, I have implemented Bootstrap Grids as seen in the image below. Check out My Bootstrap Grid Layout However, I am aiming to achieve a grid layout similar to the one shown in the picture with a red indicator. Here is the Desired Boo ...

Having trouble locating the text box using Selenium in Java. Xpath and CSS selectors are not working

I'm currently attempting to locate the textbox in the HTML snippet below using chromedriver ...

Move the close button on Bootstrap's Modal to the left side

I am currently in the process of building a new website and I am still learning HTML, CSS, and other related technologies. I am utilizing Bootstrap to assist me, but I have run into a problem. The website I am working on is in Hebrew and I am struggling to ...

Certain computers are experiencing issues with Safari where the sprites background is not resizing correctly

Currently, I am working on a responsive CSS web design project that involves incorporating various sprites for different button states. After testing the website in Firefox, Opera, IE (compatible from IE8), Chrome, and Safari, I have ensured that everythi ...

Organizing MySQL query results in PHP by displaying them in three columns with multiple rows

I am looking to feature a gallery section on my website. The layout I have in mind consists of 3 slides, with each slide containing 3 columns. The first column should be col-md-6, while the second and third columns should be col-md-3 each. Specifically, I ...

CSS: flexible side panels with stationary center

I am looking for a specific layout that consists of three columns: left, content, and right. The left and right columns will each have an image, with the left column image aligning to the left edge of the browser and the right column image aligning to the ...

Create a choppy distortion effect using CSS filters in Google Chrome

Currently working on a hover effect that enhances image brightness and scales the image during hover. However, I am experiencing some choppiness in the transform animation due to the CSS filter. It's strange because it appears to be smooth in Safari a ...

Tips for hiding an HTML tag with specific attributes from showing up in Google Chrome

Lately, I've been using a handy extension called Stylish on Google Chrome to block those annoying ads and other unwanted elements from popping up. It's quite simple - all you need is the class name or id of the tag, and you can make it disappear ...

solving the issue of CSS not loading properly on the live server

My current website is hosted on a server with the URL as follows: test1.test.com However, I need to move it to another hosting service that does not support this configuration. I had to change the URL to: test.com/test1 Everything seems to be working f ...

Images within links appear with blue lines underneath them

Currently, I am in the process of adding links to a footer by using <img> tags with SVG images. However, I am encountering an issue where there are small blue lines under the icons. After searching online, it seems that you need to add this CSS code: ...

Is there a way to place my searchbox in the top right corner of the page?

I am currently working on creating a search function for my list of products. However, I have encountered an issue where the searchBox is not appearing in the top right corner as intended. Despite trying various solutions, I have been unsuccessful in movin ...

Divide information in the chart

<table id="tab"> <tr><td class="sub">mmmmm</td><td class="sub">jjjjj</td></tr> <tr><td class="sub">lllll</td><td class="sub">wwwww&l ...

What could be causing this unexpected delay?

I have been working on improving the load time of my website as it was quite lengthy, but even after optimizations, I am facing issues specifically with the jQuery UI CSS images. If you could spare a moment, would you mind taking a look at this Pingdom te ...

Open the Bootstrap Modal for the chosen item in the table

I'm currently working on developing a basic buddy list feature for a web application. I am querying an SQL table to retrieve the list of buddies associated with the current user. Each row in the table includes a button that, when clicked, should displ ...

What would cause this to result in a blank array?

I have a main component that contains multiple sub-components, which I navigate between by clicking on different elements. These sub-components are all Vue files. What I am trying to achieve is to dynamically highlight the active component when it is bein ...

What is the best way to create a toggle effect for a <nav> bar that appears from beneath a div?

I need assistance with a navigation setup where the nav (located inside the header) needs to be connected to the bottom of a div named .menu_bar. The desired behavior is for the nav to slide down from directly underneath the .menu_bar when toggled, but cur ...

Overlapping spans

I am trying to stack these spans on top of each other without much success, http://jsfiddle.net/76NNp/79/ <td class="rtf hov"> <div>Investment</div> <div class="mub eub"> <span style="float:left">Test</spa ...

Fix background transition and add background dim effect on hover - check out the fiddle!

I'm facing a challenging situation here. I have a container with a background image, and inside it, there are 3 small circles. My goal is to make the background image zoom in when I hover over it, and dim the background image when I hover over any of ...

Issue with PHP Header Include causing navigation bar not to appear on the page

One important point to clarify: as someone who hasn't had experience with PHP, I was struggling to understand how to format the PHP file in order to display the header (nav bar) when included in the index file. Many online resources failed to explain ...