Eliminate border-radius property from Bootstrap 4 breadcrumb using Sass styling

Within Bootstrap 4, there exists a Sass variable known as $enable-rounded which

"Enables predefined border-radius styles on various components."

(https://getbootstrap.com/docs/4.1/getting-started/theming/#sass-options)

I need to eliminate the rounded corners specifically on the Breadcrumb component, while keeping them on other elements. Thus, I cannot rely on $enable-rounded for this task.

However, I am uncertain about the most efficient approach to achieve this.

The Sass code in _breadcrumb.scss looks like this:

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    padding: $breadcrumb-padding-y $breadcrumb-padding-x;
    margin-bottom: $breadcrumb-margin-bottom;
    list-style: none;
    background-color: $breadcrumb-bg;

    @include border-radius($border-radius);
}

How can I override

@include border-radius($border-radius);
without altering _breadcrumb.scss?

All the CSS for my application is consolidated into one file (app.css) compiled from a Sass file (app.scss) that initially includes the necessary Bootstrap 4 Sass files. One option could be:

// app.scss
@import breadcrumb;
@import // other_bootstrap_sass_files


// Customized CSS for my app
.breadcrumb {
    border-radius: 0;
}

This method feels reminiscent of Bootstrap 3, where overriding was necessary.

Is there a more sophisticated way to accomplish this using Sass in Bootstrap 4?

Answer №1

In your specific scenario where you are looking to exclude border-radius from breadcrumbs while keeping it for all other components, the only way to achieve this is by following the approach mentioned in your question:

.breadcrumb {
      border-radius: 0;
  }

This might remind you of Bootstrap 3 where customization was needed to remove unwanted styles.

From my perspective, making modifications directly to the original _breadcrumb.scss file seems like the most straightforward option if you wish to maintain consistency across your design elements.

Answer №2

When you open the _variables.scss file, you'll find all the variables specified with !default - it's like a user preferences file. During compilation of SCSS, your new values will replace the default ones without needing to override the CSS.

It seems that

$breadcrumb-border-radius: $border-radius !default;
is what you're looking for.

Here are two methods to reset that value:

1) Create a duplicate of the _variables.scss file and save it in your project folder (you can rename it to something like _myvariables.scss), locate the variable, remove the !default, and change it to $breadcrumb-border-radius: 0; OR 2) Create a new file, let's say _myvariables.scss, containing $breadcrumb-border-radius: 0; (along with any other default values you wish to modify later).

Then, ensure you import this new file BEFORE your bootstrap scss. In your case, this would be in your app.scss file:

// app.scss
@import myvariables.scss; //no underscore needed because it's a partial
@import // other_bootstrap_sass_files including the breadcrumb component

Now, after compiling the SCSS, the breadcrumb radius will be set to 0 without affecting anything else or having to overwrite any css properties.

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

The functionality of my website is not optimized for viewing on iPhones

While designing a responsive website that looks great on most devices, I noticed some issues with iPhones. The layout breaks in two specific ways on these devices. View Galaxy Screenshot View Sony Screenshot The menu doesn't scale properly on iPho ...

How to display a specific HTML section to a select group of individuals using PHP

I have created a section in HTML that I only want to be visible to individuals whose if($Admin >= 1) condition is met based on my database. However, I am uncertain about how to implement this. This is the current state of my HTML code. !-- ADM SECTIO ...

Modifying app aesthetics on-the-fly in Angular

I am currently working on implementing various color schemes to customize our app, and I want Angular to dynamically apply one based on user preferences. In our scenario, the UI will be accessed by multiple clients, each with their own preferred color sch ...

Issue with Bootstrap 4: Dropdown Button Not Functioning

'<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tag ...

Arranging the rows and columns of a table in optimal alignment

I am currently facing an issue with two tables. The first table consists of 2 rows and 4 columns, with the first column spanning 2 rows. However, in the visual representation, the last 3 columns are misaligned with the rows. How can this alignment be corre ...

Unable to relocate CSS Loader Container

Can someone help me with adjusting the placement of my container? I'm struggling to maintain the styles while getting rid of the position: absolute; on the .dot class. Every attempt I make is resulting in the dots moving erratically! To clarify, I w ...

Tips on displaying two columns as a single column on mobile devices

Bootstrap 3 table is described as: <style> /* Overriding Bootstrap style to ensure description text wraps into multiple rows on mobile */ .details-propertyvalue { white-space:normal !important; } </style> <table class="table table-hove ...

Transition CSS applied only to links containing images

I am trying to figure out how to apply a transition effect only on links that have images, rather than text. Specifically, I want the transition effect to be applied only to the second link in the following example: <a href="#">no image</a> &l ...

The Benefits of Semantic Class Names compared to Microdata

As I strive to use semantic class names, my exploration of microdata and SEO raises a question: Is it necessary to use both? Compare these two HTML snippets representing an event: Using CSS classes: <div class="event" itemscope itemtype="http://schema ...

What is the best way to show a label and select box side by side using Angular Material?

I have been trying to keep input and label in the same line using Angular Material, but I haven't found a solution yet. Most of the available solutions are in HTML and CSS, but I specifically need a way using Angular Material. The method I tried invo ...

What is the best way to have an image fill the remaining space within a 100vh container automatically?

I have a container with a height of 100vh. Inside it, there is an image and some text. The text's height may vary based on the screen size and content length. I want the text to occupy its required space while the image fills up the remaining availabl ...

Validation failures frequently occur in the typeahead feature of Angular 2 when using Bootstrap 4, despite a value being selected

I need to implement an auto-complete feature using Bootstrap Typeahead in a form I am currently working on. <input [(ngModel)]="model.brand" [typeahead]="model.brands" ng-model-options="{'updateOn': 'blur'}" (typeaheadOnSele ...

What is the recommended way to compile SCSS module in a Vue component using Laravel Mix?

I recently attempted to set up the webpack configuration in my Laravel project. However, I encountered an issue where modular CSS was working perfectly fine without the lang="scss" attribute, but now I need to work with SCSS. I'm struggling to figure ...

Navigation Menu Dropdown Present on the Right Side and Arranged in a Horizontal Stack

I'm having trouble with a dropdown menu in my navigation bar. I followed the example on W3Schools but when I hover, the menu appears horizontally instead of vertically and to the far right of the page. I've searched for solutions but can't s ...

The two divs are positioned on top of one another, with the link in the bottom div being unclickable

I am trying to create a unique effect where a tile divides into two on hover, with each tile acting as an individual link. Additionally, I want the background color of the tiles to change on hover. To achieve this, I have stacked two divs (toptile and bot ...

Convert the HTML content into a PDF while retaining the CSS styles using either JavaScript or Django

Looking to create a PDF of an HTML element with background color and images. Seeking a solution, either client-side or server-side using Django/Python. Tried jsPDF on the client side, but it does not support CSS. Considering ReportLab for Django, but uns ...

"Final" design not functioning properly. Margins

CSS .col-3 { width:31.5%; float:left; margin-right:1.8%; margin-bottom:1.6949%; display:block; } .last { width:31.5%; float:left; margin-right:0; margin-bottom:1.6949%; display:block; } When using the code ...

Opening a modal in Bootstrap 4 selectpicker depending on the chosen value

I am facing an issue with a selectpicker that has live search functionality. I want to trigger a modal to open only when the user clicks on the option that says "Add new contractor." However, this modal is currently opening for all options, even though I o ...

How can a div fill the remaining vertical space, despite the dynamic height of the div above it?

Check out my code snippet on JSFiddle: http://jsfiddle.net/nom4mxLt/ <div id="wrapper"> <div id="yellow">variable height (I put 200px but can change in realtime)</div> <div id="red">This one should fill all remaining space ...

How come my gifs appear tiny even though I've adjusted their width to 32% each?

I am trying to display three gifs in a row, each taking up one-third of the width of the page. However, when I preview the page, the gifs appear tiny. I have set the divs to 32% each and the gifs should fill 100% of their respective div. Here is the code s ...