How to Remove the Arrow in Dropdown in Bootstrap

How to Remove the Arrow in Dropdown in Bootstrap?

In this tutorial, we will learn how to remove the arrow in the dropdown in Bootstrap. A drop-down is a compact version of a list box. It shows one item initially but reveals the complete list when clicked. In Bootstrap, you can use the Bootstrap dropdown component for this purpose. It allows you to have a predefined list of items that users can select by clicking on it.

Whether crafting a user-friendly form, a versatile navigation bar, or a dynamic settings menu, the Bootstrap dropdown serves as an invaluable companion, enriching the user experience and streamlining interactions. It effortlessly manages a predefined set of choices, streamlining decision-making, reducing cognitive load, and ensuring smoother user journeys.

Thus, within the realm of web development, the Bootstrap dropdown stands tall, embodying the fusion of simplicity, elegance, and practicality. It beautifully balances hiding and revealing informationβ€”a delightful dance between engagement and convenience, accessible to developers and users alike.

How to Create an Arrow Dropdown in Bootstrap?

To create a simple dropdown using Bootstrap, you’ll need an HTML file with the necessary Bootstrap CSS and JavaScript included.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Bootstrap Dropdown Example</title>
  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
</head>
<body>
  <div class="container mt-5">
    <h1>Bootstrap Dropdown Example</h1>
    <div class="dropdown">
      <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        Dropdown
      </button>
      <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
        <!-- Dropdown items go here -->
        <a class="dropdown-item" href="#">Item 1</a>
        <a class="dropdown-item" href="#">Item 2</a>
        <a class="dropdown-item" href="#">Item 3</a>
      </div>
    </div>
  </div>

  <!-- Bootstrap JavaScript (popper.js is required for dropdowns) -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

Save the above code in an HTML file (e.g., index.html) and open it in your web browser. You should see a button labeled “Dropdown.” When you click on the button, the dropdown menu will appear, showing the three sample items (“Item 1,” “Item 2,” and “Item 3”).

Removing the Arrow from the dropdown in Bootstrap

By adding the below CSS, the arrow can be removed.

<style>
    /* Custom CSS to remove the caret arrow */
    .dropdown-toggle::after {
      display: none;
    }
</style>

Example:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Bootstrap Dropdown Example</title>
  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
  <style>
    /* Custom CSS to remove the caret arrow */
    .dropdown-toggle::after {
      display: none;
    }
  </style>
</head>
<body>
  <div class="container mt-5">
    <h1>Bootstrap Dropdown Example</h1>
    <div class="dropdown">
      <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        Dropdown
      </button>
      <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
        <!-- Dropdown items go here -->
        <a class="dropdown-item" href="#">Item 1</a>
        <a class="dropdown-item" href="#">Item 2</a>
        <a class="dropdown-item" href="#">Item 3</a>
      </div>
    </div>
  </div>

  <!-- Bootstrap JavaScript (popper.js is required for dropdowns) -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

In the above code, we’ve added a <style> block within the <head> section to include the custom CSS that targets the .dropdown-toggle::after pseudo-element and sets its display property to none. This effectively hides the caret arrow, giving the appearance of a dropdown without the arrow.

Now, when you open the HTML file in your web browser, you should see the dropdown without the arrow next to the “Dropdown” label.

Check out My Latest post on Developer Helps for some Interesting Insights