snehilvj / dash-iconify

Iconify for Plotly Dash
https://www.dash-mantine-components.com/dash-iconify
MIT License
52 stars 2 forks source link

Flickering icons #10

Open Andre-Medina opened 1 week ago

Andre-Medina commented 1 week ago

When the page loads and before the icon has been drawn, the DashIconoify element width is 0px, then once the icon is drawn the width goes to e.g. 16px. This causes horizontal flickering.

            dmc.Button(
                children="label", 
                leftSection=DashIconify(icon=my_icon, height = 16, width =16),
                ),
            ), 

Buttons flicker (Note: each of these buttons redirects the page and reloads the icons): icons flickering

I recommend, if the height or width kwargs are passed. To set the width/ heigh to that value of the Div before the icon is drawn. This will remove the flickering.

Adding div with constant width

            dmc.Button(
                children="label", 
                leftSection= html.Div(
                    DashIconify(icon=my_icon, height = 16, width =16),
                    style = {"width": "16px"}
                ),
            ), 

Flickering is removed: icons not flickering

AnnMarieW commented 1 week ago

Nice tip! Thanks for sharing :slightly_smiling_face: