Skip to content

[BUG] dcc.Dropdown aligns menu items incorrectly when using a nonzero margin #3368

Open
@J-Thus

Description

@J-Thus

Environment

Python 3.13.5
dash                      3.1.1
- OS: Windows 11
- Browser: Firefox
- Version: 140.0.4 (64-bit)

Description

MWE:

import dash
from dash import dcc, html

app = dash.Dash(__name__)

dropdown_style = {
    "margin": "50px",
}


app.layout = html.Div(
    [
        dcc.Dropdown(
            id="drop-select",
            options=[
                {"label": "foo", "value": "foo"},
                {"label": "bar", "value": "bar"},
            ],
            value="foo",
            style=dropdown_style
        ),
    ]
)


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

Adjusting the margin doesn't affect the dropdown and its items in the same way. The items are positioned incorrectly. Also affected by "margin-left".

Expected behavior

The items should be flush with the dropdown.

Screenshots

Bug with margin of 50px.

Image

Expected behavior (reproduced without using a margin).

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions