Centering Tabs in React-Bootstrap

By default, Bootstrap-react's tabs align to the left.

<Tabs defaultActiveKey={2} id="uncontrolled-tab-example">
  <Tab eventKey={1} title="Tab 1">
    Tab 1 content
  </Tab>
  <Tab eventKey={2} title="Tab 2">
    Tab 2 content
  </Tab>
</Tabs>;

To align the tabs to the right, you can use the pullRight prop.

<Tabs pullRight defaultActiveKey={2} id="uncontrolled-tab-example">

Is there a simple way to center the tabs? If not, how would you go about centering them?

Answer №1

To style your navigation menu, add the following CSS code to your stylesheet:

ul.nav.nav-tabs {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px;
}

Answer №2

To apply the fill as a property, simply add it to the component

<Tabs fill></Tabs>

Answer №3

Maybe try this:

.menu-tabs > li {
  float: none;
  display: inline-block;
  zoom: 1;
}

.menu-tabs {
  text-align: center;
}

Check out this example: http://jsfiddle.net/u68c3je9/2/

Answer №4

.centered-tabs > nav {
  display: flex;
  flex-direction: row;
  justify-content: center;
}
<div className='centered-tabs'>
  <Tabs></Tabs>
</div>

Answer №5

One technique that proved successful for me was utilizing the grid system within react-bootstrap and incorporating the "nav-justified" class into the column.

<Container fluid>
  <Row className={"justify-content-center"}>
    <Col className={"nav-justified"}>
      <Tabs defaultActiveKey="profile" id="uncontrolled-tab-example">
        <Tab eventKey="user" title="User"></Tab>

        <Tab eventKey="aboutMe" title="About Me"></Tab>

        <Tab eventKey="posts" title="Posts"></Tab>
      </Tabs>
    </Col>
  </Row>
</Container>;

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

Arrange the navigation bar in a straight line

I am facing an issue with my navigation bar... I want it to be centered but it is not working. I want it to fill from left to right. I have tried using the following CSS: text-align: center in .navbar a text-align: center in navbar. .navbar { backgr ...

Retrieving a page using jQuery

Below is the JavaScript code that I am using: $.ajax({ url: "test.html", error: function(){ //handle error }, success: function(){ //perform actions here with the received data } }); After retrieving test.html, I am wo ...

Is there a way to modify the font color in Chrome when the input autofill feature is active?

I tried adding the css code below: input:-webkit-autofill{ color:white; } Unfortunately, it didn't have any effect. If anyone can assist me with this issue, I would greatly appreciate it. Thank you. ...

flexbox wrapping text styling

Can text be wrapped in flex within a fixed width container? For example: img username added you as a friend Instead of: user added img name you as a friend I am able to achieve this if the image and 'a' were separat ...

Side Menu with Fixed Position Created with Tailwind CSS

Can anyone help me create a social media sidebar that stays fixed on the bottom right side of the screen, regardless of its size? Currently, the sidebar moves when I scroll down, but I want it to remain in place. How can I achieve this fixed positioning? ...

Discovering descendant div elements

I've been conducting some research, but I'm struggling to find a specific answer for this. Here is the HTML code snippet: <div class="collapsingHeader"> <div class="listItemWrapper"> <div class="itemWrapper"> ...

Increasing the grid size in React Bootstrap 5 for added flexibility

Customizing React Bootstrap Sizes WPW Container Max-Width sx < 576px - none sm > 567px - 540px md > 768px - 720px lg > 992px - 960px xl > 1200px - 1140px xxl > 1400px - 1320px Desiring a New Size Category: I am interested in ad ...

Guide: Writing code that caters to different types of media in React using Material-UI

After reviewing the documentation, I believed that the optimal solution in later versions of material-ui was to use useMediaQuery, but unfortunately, I am unable to implement it correctly. My objective is to hide a menu when the page is being printed, so I ...

JavaScript (Create a button that toggles the visibility of an element)

I have implemented a hamburger menu that transforms into an x when clicked. I am looking to modify it so that clicking on the hamburger opens the menu, and clicking on the x closes the menu. Below is the code I have been working with: <!DOCTYPE html&g ...

Curvature Factor equals Overflow of Color

After trying various solutions like "background-clip: padding-box;" to address the issue of background color bleeding outside of the border, I'm still not completely satisfied with the result. Is there a more effective fix for this problem? Check out ...

Position the checkbox to the left of the label

I currently have a checkbox with ripple effects. The label text is displayed before the checkbox in the code. However, I'd like to change the order so that the checkbox comes before the label text. Occasionally, the entire div expands and contracts. ...

Is there a way to move the navbar to the right side of the screen?

How do I create a navigation menu that takes up half of the screen on the left side while allowing for scrolling on the right side without moving the navigation? What I am aiming for is similar to the images linked below: example example I attempted to u ...

Conditionals in Angular 2 using Sass

Looking to apply this style with Sass or CSS: IF :host.form-control MATCHES .ng-valid[required] OR .ng-valid.required THEN :host ::ng-deep input.form-control = border-left: 5px solid #42A948; Appreciate the help! ...

The issue with async/await functionality in Intersection Observer

On my website, I have implemented an Intersection Observer that monitors a specific element in the viewport. The observer triggers a series of classList.add() and classList.remove() methods, applying different animate.css animation classes. Everything work ...

What is the best way to use jQuery to attach functions to every input element?

Imagine you have a set of HTML markup and CSS like this: #CSS .inputhelp_text { background: #000; color: #fff; } .nodisplay { display: none; } <input class="inputhelp" id="firstname" /><span class="inputhelp_text nodisplay" id="help_firstname"& ...

Tips for adjusting the div style when resizing the browser

As I work on a script, I encounter an issue where the style of a div should change when it becomes larger due to resizing. Even though I have come up with a solution for this problem, there are still some inconsistencies. Sometimes the width is reported a ...

Tips for organizing nested form rows with Bootstrap 4

I am currently working on a nested form row and I am looking to align the form fields vertically. The current output I am getting is shown below: https://i.sstatic.net/NEWGY.png Here is the code snippet: <link rel="stylesheet" href="https://maxcdn ...

Are there any improved methods for optimizing the CSS in my Next.js project?

Currently, I'm immersed in a project using Next.js and styling it with CSS in JS (ReactJSS). Upon inspecting the page source, I noticed that there are over 4000 lines of CSS for a single page, which is not ideal for performance. To provide context, l ...

Trouble triggering hidden radio button in Angular 9 when clicked

I have implemented radio buttons within a div with the following CSS styles (to enable selection by clicking on the div): .plans-list { display: flex; justify-content: center; margin: 2rem 0; .plan { display: flex; margin: 0 0.5rem; p ...

Distinguish a specific div within a group of divs by styling it uniquely using just CSS and HTML

I need assistance in selecting the first div with both "con" and "car" classes among all the divs using a CSS selector. <div class="box"> <div class="con">1</div> <div class="con be">2</div> <div class="con car">3& ...