How to customize the arrow color of tooltips in Bootstrap 4

After spending an hour searching online, I still can't figure out how to change the tooltip arrow color to red. None of the code snippets I found seem to work for me.

My latest attempt was:

.tooltip-arrow {
  border-right-color: red;
  border-left-color: red;
  border-bottom-color: red;
  border-top-color: red;
}

The tooltip arrow is pointing left and positioned to the right.

Answer №1

If you are using bootstrap 4.1, you have the option to customize tooltips with the following CSS:

.bs-tooltip-auto[x-placement^=bottom] .arrow::before, .bs-tooltip-bottom .arrow::before {
    border-bottom-color: red !important;
}
.bs-tooltip-auto[x-placement^=top] .arrow::before, .bs-tooltip-top .arrow::before {
    border-top-color: red !important;
}
.bs-tooltip-auto[x-placement^=left] .arrow::before, .bs-tooltip-left .arrow::before {
    border-left-color: red !important;
}
.bs-tooltip-auto[x-placement^=right] .arrow::before, .bs-tooltip-right .arrow::before {
    border-right-color: red !important;
}

Answer №2

Incorporating Bootstrap 4.3.1

Integration in HTML Document

<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="top" title="Tooltip on top">
  Tooltip on top
</button>

Implementation in CSS File

.tooltip-inner {
    background-color: red;
    color: #444;
    width: auto;
    max-width: 150px;
    font-size: 100%;
    white-space: nowrap;
}

.bs-tooltip-auto[x-placement^=top] .arrow::before, .bs-tooltip-top .arrow::before {
    border-top-color: red;
}
.bs-tooltip-auto[x-placement^=right] .arrow::before, .bs-tooltip-right .arrow::before {
    border-right-color: red;
}
.bs-tooltip-auto[x-placement^=bottom] .arrow::before, .bs-tooltip-bottom .arrow::before {
    border-bottom-color: red;
}
.bs-tooltip-auto[x-placement^=left] .arrow::before, .bs-tooltip-left .arrow::before {
    border-left-color: red;
}

Addition to Javascript File

$(document).ready(function () {
    $('.btn').tooltip();
});

Answer №3

Here is the specific selector to use for the tooltip arrow color change:

.tooltip.bs-tether-element-attached-left .tooltip-inner::before
:

.tooltip.bs-tether-element-attached-left .tooltip-inner::before {
    border-right-color: red;
}

To make all tooltip arrows red, you can check out this link for the code on jsfiddle: jsfiddle:

.tooltip.bs-tether-element-attached-bottom .tooltip-inner::before {
    border-top-color: red;
}

.tooltip.bs-tether-element-attached-top .tooltip-inner::before {
    border-bottom-color: red;
}

.tooltip.bs-tether-element-attached-left .tooltip-inner::before {
    border-right-color: red;
}

.tooltip.bs-tether-element-attached-right .tooltip-inner::before {
    border-left-color: red;
}

Answer №4

After implementing this code in my Bootstrap 4.0.0-beta.2 project, I was pleased to see that it worked perfectly.

.tooltip.bs-tooltip-bottom .tooltip-inner {
    background:#444 !important;
}

.tooltip .arrow:before {
 border-bottom-color:#444 !important;
 border-top-color:#444 !important;
 }

Answer №5

Upgrade to Bootstrap 4.0.0 combined with Popper.js library.

Create a left arrow tooltip effect:

.tooltip .tooltip-inner {
  background-color: green;
}

.tooltip .arrow::before {
  border-left-color: green;
}

Easily incorporate this into your CSS code.

Answer №6

When customizing bootstrap 4.3 tooltip styles, I typically use the following approach:

/*Tooltip*/
.tooltip {
  font-family: "Roboto", "Tahoma", "Helvetica", sans-serif;
}

.tooltip > .arrow::before {
  border-bottom-color: #757E94;
}

.tooltip-inner {
  background-color: #757E94;
  color: white;
  font-style: italic;
}

Answer №7

A handy jQuery plugin that allows for customizing the color of tooltip arrow:

(function($) {
    $.fn.colortips = function(){
        return this.each(function() {
          var tt = $(this);
          tt.on('focus mouseenter', function(){
            var bc = tt.css('background-color');
            var tc = (tt.data('color')===undefined || tt.data('color')==='') ? '' : tt.data('color');
            var pt = tt.data('placement');
            $('.bs-tooltip-bottom.show .tooltip-inner').css({
              'background-color': bc,
              'color': tc
            });
            $('<style id="colortips-style">.bs-tooltip-bottom.show .arrow::before{border-'+pt+'-color: '+bc+';}</style>')
              .appendTo('head');
          }).on('focusout mouseleave', function(){
            $('.bs-tooltip-bottom.show .tooltip-inner').css({
              'background-color': '',
              'color': ''
            });
            $('#colortips-style').remove();
          });
        });
    }
}(jQuery));

View a live example here.

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

An unusual outcome occurred while attempting to duplicate the text

After copying the letter A, I noticed that an empty string is being logged to the console instead of the expected A. However, when I paste, the console does successfully log the letter A. document.addEventListener('copy', handler); document ...

Ways to prevent a div containing a lengthy content string from extending beyond other divs

Check out my Codepen project here Here is the HTML code for my personal website: <div id="splash" class="divider"> <h1 class="text-center text-uppercase">vincent/rodomista</h1> <p class="text-center text uppercase">Full Stack ...

Customizing CSS Styles in ASP.NET MVC for Multilingual Websites

We are looking to make our ASP-MVC website multicilingual and support different languages. One challenge I am facing is how to apply distinct style-sheets for each language, especially when dealing with right-to-left (RTL) languages like Hebrew or Arabic c ...

What is the best way to align my logo image and search field at the center of the page, similar to the layout of

Struggling with styling this webpage. I aim to have my logo and search bar centered on the page, surrounded by ample space above and below. You can check it out at NE1UP dot com. All I want is a Google-style layout for my page, but I'm facing difficu ...

Personalized cursor image using jQuery.css()

I have designed a .png image that I want to use as a custom cursor for a particular element with the class "next". Here is the code I am using, but it doesn't seem to be working. Is there anything important that I may have overlooked? $('.next& ...

"Discover the magic of jQuery: Unveiling the hidden div with one simple CSS visibility change

I want to implement a functionality on my screen where the Previous button is hidden initially and only becomes visible when the user clicks the Next button. I have set the CSS property for the Previous button to hide it by default, but despite using an if ...

Display a fancy slideshow that transitions to five new images when the last one is reached

Here is a screenshot of my issue: https://i.stack.imgur.com/duhzn.png Incorporating Bootstrap 3 and FancyBox, I am facing an issue with displaying images in rows. When I reach the last image, clicking on the right arrow should result in sliding to anothe ...

What is the best way to set a specific image as the initial image when loading 'SpriteSpin'?

I'm currently working on creating a 360-degree view using the SpriteSpin API. Everything is functioning as expected, but I have an additional request. I need to specify a specific image to be the initial landing image when the page loads. The landing ...

Bootstrap grid with 4 columns featuring text of varying lengths and styles

I currently have a layout on my webpage that consists of four columns. Each column includes a logo, an <h2> tag, and a <p> tag. My issue is with aligning the paragraphs horizontally so they match consistently. Whenever the text in the <h2&g ...

Obtain a masterpiece by creating a canvas in React

Greetings! I have developed a drawing app using react and I am looking for a way to capture what the user has drawn on the canvas when they release the mouse button. This process should repeat continuously until the user stops drawing. Can anyone suggest h ...

Discover the position of a dynamically added element

Is there a way to identify the specific dynamically added checkbox that was clicked, whether by index or name? I came across a similar question with a solution in this JSFiddle: JSFiddle Instead of just displaying "clicked", I would like it to show someth ...

Apply a unique design to a class by clicking on a button

There are 3 identical boxes with the same classes and a button: function changeColorAndAddPadding() { /* ??? */ } .box { border: 1px solid; display: inline; } <button onclick="changeColorAndAddPadding();">Click Here</button> <d ...

Grid of squared CSS elements contained within a wrapper div that is set to a maximum

When attempting to create a CSS grid layout with square boxes, I encountered an issue. While the first row of squares remains square when setting the maximum height of the wrapper, subsequent rows are cropped into rectangles instead. The culprit seems to b ...

Alert message in jQuery validation for the chosen option value

I am attempting to validate a combo box with the code provided below. Currently, I receive multiple alert messages even if one condition is true. My goal is to only display one alert message when a condition is met and highlight the other values in red. Th ...

Tips on adjusting CSS code to ensure that a single accordion panel is open when the page first loads

I have a code that is functioning perfectly. However, I need to make a modification so that there is a default panel open when the page loads or refreshes. #acc-label { display: block; float: left; height: 330px; width: 50px; margin-bottom: 10px ...

Creating unsightly class names using Node.js

Is it possible to automatically create random and unattractive class names? For example, is there a tool or plugin that can substitute the .top-header class with something like .a9ev within my CSS code? It would also be ideal if the class name in the HTML ...

What are the essential Bootstrap CSS and JavaScript files that need to be connected to our HTML document?

I recently downloaded the most recent version of Bootstrap, which is version 4. Upon extraction, I noticed that it includes two folders: one for CSS and the other for JS. The CSS folder consists of approximately 12 CSS files, while the JS folder contains ...

Issue: Node.js Express unable to access static files when the route is nested more than one folder level deep.Resolution

Before we delve into the question, let me share with you the folder structure of my node.js express app: /home server.js index.html /app /routes public.js /public /css main.css In my server.js file, ...

Arranging pseudo elements using CSS Grid

I am currently working on positioning pseudo-elements on a grid, following the specification. It seems to be working well for my overall layout set on the <body>, however, I am facing difficulties when it comes to the <header> element which is ...

Manipulate the css pseudo-element :after using jQuery's .siblings() method

How can I use jQuery to edit the :after element created by CSS? <div class="box"> <h3 class="social">Social</h3> <ul> <li><a href="https://www.youtube.com/" onmou ...