I am aiming to customize the nav-pills to appear in a bold red color. After reviewing information on these two pages
- https://getbootstrap.com/docs/4.4/utilities/colors/#background-color
- https://getbootstrap.com/docs/4.4/components/buttons/
I gathered that simply adding a predefined color within <div class "">
should suffice.
Desiring a vibrant red shade, I experimented with the following:
.bg-danger
red
btn btn-danger
Although switching from nav-pills
to btn btn-danger
altered the appearance, it was not as desired due to an overall unattractive form. This led me to believe that the pill vertical code may not be compatible with button colorization methods. Attempting to implement .bg-danger
or red
resulted in no visible changes. Despite 'red' not being listed on the referenced pages, I experimented because it is defined in the main bootstrap.css file.
:root {
lots of other colors;
--red: #dc3545;
lots of other colors;
}
I attempted variations such as red
, -red
, --red
, .bg-red
, and .bg--red
without success. Noteworthy, I adjusted the color codes to match my preferred red here (using bootstrap's danger red to maintain consistency if I overlooked something).
How can I successfully override the color without directly editing the 4 css files? Or have I inadvertently chosen a feature that has limited customization?
Default code displaying pills in blue (assuming availability of the bootstrap files).
<div class="col-3">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<a class="nav-link active" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</a>
<a class="nav-link" id="v-pills-profile-tab" data-toggle="pill" href="#v-pills-profile" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</a>
<a class="nav-link" id="v-pills-messages-tab" data-toggle="pill" href="#v-pills-messages" role="tab" aria-controls="v-pills-messages" aria-selected="false">Messages</a>
<a class="nav-link" id="v-pills-settings-tab" data-toggle="pill" href="#v-pills-settings" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</a>
</div>
</div>
<div class="col-9">
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">...</div>
<div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">...</div>
<div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab">...</div>
<div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab">...</div>
</div>
</div>
</div>
The revised code utilizing the .bg--red
modifier. Apologies for any formatting inconsistencies, my attempts at highlighting were unsuccessful using
<pre class="prettyprint">...</pre>
.
<div class="col-3">
<div class="nav flex-column nav-pills .bg--red" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<a class="nav-link active" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</a>
<a class="nav-link" id="v-pills-profile-tab" data-toggle="pill" href="#v-pills-profile" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</a>
<a class="nav-link" id="v-pills-messages-tab" data-toggle="pill" href="#v-pills-messages" role="tab" aria-controls="v-pills-messages" aria-selected="false">Messages</a>
<a class="nav-link" id="v-pills-settings-tab" data-toggle="pill" href="#v-pills-settings" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</a>
</div>
</div>
<div class="col-9">
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">...</div>
<div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">...</div>
<div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab">...</div>
<div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab">...</div>
</div>
</div>
</div>
edit1
Just to clarify, my ultimate goal is to change the activated pill menu item to a captivating red instead of the default blue. Modifying the <div class="">
alteration has mostly affected the form background itself, resulting in an unattractive outcome; however, it did not alter the displayed activated pill background. I am uncertain if this level of customization is feasible without directly modifying the .css. Currently, the only way I can achieve the desired result is by directly editing the 4 .css files containing references to the pill colors. I am optimistic that there exists an approach to achieve this at a higher level, particularly if I wish to incorporate various menus with distinct color schemes.