# Align Dash Bootstrap Components NavLinks in Navbar

**URL:** <https://community.plotly.com/t/align-dash-bootstrap-components-navlinks-in-navbar/59311>\
**Category:** Dash Python\
**Created:** [December 15, 2021, 9:49pm UTC](https://community.plotly.com/t/align-dash-bootstrap-components-navlinks-in-navbar/59311 "2021-12-15T21:49:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mawe](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@mawe](https://community.plotly.com/u/mawe)\
**Post date:** [December 15, 2021, 9:49pm UTC](https://community.plotly.com/t/align-dash-bootstrap-components-navlinks-in-navbar/59311/1 "2021-12-15T21:49:55Z")

</div>

Hi community!

Using the example from the Dash Bootstrap Components (dbc) 1.0.2 documentation, I am trying to implement a NavBar navigation bar. I want to layout some of the NavLinks to the left, and some special ones, e.g., ‘Help’, ‘About’ or ‘Login’ items to the right. With the code below, all items are aligned to the right. I tried multiple combinations of dbc.Rows and dbc.Cols but did not have any success. I assume, there are specific css keywords that would be helpful.

```
    header = dbc.Navbar(
    dbc.Container(
        [
            html.A(
                dbc.Row([
                    dbc.Col(dbc.NavbarBrand("Title", className="ms-2"))
                ], align="center", className="g-0"), href="/", style={"textDecoration": "none"}
            ),
            dbc.Row([
            dbc.NavbarToggler(id="navbar-toggler"),
            dbc.Collapse([
                dbc.Nav([
                    dbc.NavItem(dbc.NavLink("Home")), # these should go to the left
                    dbc.NavItem(dbc.NavLink("Page 1")),
                    dbc.NavItem(dbc.NavLink("Page 2")),

                    dbc.NavItem(dbc.NavLink("Help")), # these should go the right
                    dbc.NavItem(dbc.NavLink("About"))
                ])
            ], id="navbar-collapse", is_open=False, navbar=True)
            ])
        ],
        fluid=True,
    ),
    dark=True,
    color="dark"
)

```

I found a similar discussion in an old [stackoverflow](https://stackoverflow.com/questions/44629140/how-to-divide-menus-to-left-and-right-in-bootstrap/44629427) topic, and although the solution in pure html looks straightforward, I failed to transfer it to my problem. I am fairly inexperienced with css, so any help and pointers towards relevant documentation would be highly appreciated!

---

<div class="post-metadata">

**Author:** ![dataturnsmeon](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dataturnsmeon](https://community.plotly.com/u/dataturnsmeon)\
**Post date:** [December 18, 2021, 4:36pm UTC](https://community.plotly.com/t/align-dash-bootstrap-components-navlinks-in-navbar/59311/2 "2021-12-18T16:36:40Z")

</div>

@mawe did you find any solution to this?

Even I am trying to align few items inside the collapsed menu (when not collapsed) to the left on my navbar and keep others at right but failing do so.

---

<div class="post-metadata">

**Author:** ![tcbegley](https://avatars.discourse-cdn.com/v4/letter/t/46a35a/32.png) [@tcbegley](https://community.plotly.com/u/tcbegley)\
**Post date:** [December 18, 2021, 5:30pm UTC](https://community.plotly.com/t/align-dash-bootstrap-components-navlinks-in-navbar/59311/3 "2021-12-18T17:30:31Z")

</div>

You can achieve this using some of [Bootstrap’s utility classes](https://getbootstrap.com/docs/5.0/utilities/flex/).

You need the following three changes:

- Add `className="flex-grow-1"` to the `Row` to make sure it expands to fill the available horizontal space.
- Add `className="w-100"` to the `Nav` to make sure it is the full width of the `Row`
- Add `className="me-auto"` after the last left aligned link, to create an auto margin that pushes the remaining links to the end.

Here’s your example with these changes

```python
import dash_bootstrap_components as dbc
from dash import Dash, html

app = Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])

header = dbc.Navbar(
    dbc.Container(
        [
            html.A(
                dbc.Row(
                    dbc.Col(dbc.NavbarBrand("Title", className="ms-2")),
                    align="center",
                    className="g-0",
                ),
                href="/",
                style={"textDecoration": "none"},
            ),
            dbc.Row(
                [
                    dbc.NavbarToggler(id="navbar-toggler"),
                    dbc.Collapse(
                        dbc.Nav(
                            [
                                dbc.NavItem(dbc.NavLink("Home")),
                                dbc.NavItem(dbc.NavLink("Page 1")),
                                dbc.NavItem(
                                    dbc.NavLink("Page 2"),
                                    # add an auto margin after page 2 to
                                    # push later links to end of nav
                                    className="me-auto",
                                ),
                                dbc.NavItem(dbc.NavLink("Help")),
                                dbc.NavItem(dbc.NavLink("About")),
                            ],
                            # make sure nav takes up the full width for auto
                            # margin to get applied
                            className="w-100",
                        ),
                        id="navbar-collapse",
                        is_open=False,
                        navbar=True,
                    ),
                ],
                # the row should expand to fill the available horizontal space
                className="flex-grow-1",
            ),
        ],
        fluid=True,
    ),
    dark=True,
    color="dark",
)

app.layout = html.Div(
    [header, dbc.Container(html.P("This is some content"), className="p-5")]
)

if __name__ == " __main__":
    app.run_server(debug=True)

```

---

<div class="post-metadata">

**Author:** ![mawe](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@mawe](https://community.plotly.com/u/mawe)\
**Post date:** [December 18, 2021, 7:36pm UTC](https://community.plotly.com/t/align-dash-bootstrap-components-navlinks-in-navbar/59311/4 "2021-12-18T19:36:25Z")

</div>

Thanks a lot @tcbegley! I guess, it is time to learn some bootstrap!
