I’m trying to use Bootstrap’s Carousel element because the component from dbc doesn’t support anything but images, and I want a carousel for dcc.Graph components. So to start off, I tried making a minimal example using the official bootstrap carousel example as a guide… but it doesn’t work (the contents don’t “carouse”), and I don’t know why. Here is the code:
import dash
from dash import html
external_scripts = [
{
"src": "https://code.jquery.com/jquery-3.3.1.slim.min.js",
"integrity": "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo",
"crossorigin": "anonymous",
},
{
"src": "https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js",
"integrity": "sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM",
"crossorigin": "anonymous",
},
]
external_stylesheets = [
{
"href": "https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css",
"rel": "stylesheet",
"integrity": "sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T",
"crossorigin": "anonymous",
}
]
app = dash.Dash(
__name__,
external_scripts=external_scripts,
external_stylesheets=external_stylesheets,
)
app.layout = html.Div(
[
html.Div(
id="carouselExampleSlidesOnly",
className="carousel slide",
**{"data-ride": "carousel"},
children=[
html.Div(
className="carousel-inner",
children=[
html.Div(
className="carousel-item active",
children=[html.P("one")],
),
html.Div(
className="carousel-item",
children=[html.P("two")],
),
html.Div(
className="carousel-item",
children=[html.P("three")],
),
],
)
],
)
]
)
if __name__ == "__main__":
app.run_server(debug=True)
What is interesting, is that if you check the browsers inspect tool, then everything needed seems to be in place. After removing all dash related addons, the remaining html works as expected, as can be seen here on jsfiddle:
https://jsfiddle.net/rhgb9cjp/
Any help would be much appreciated, as I’ve also tried using Carousel from dash_trich_components, but it is extremely buggy and no longer maintained. I’m almost at the point I regret not just making my entire project in raw html/css/js.
P.s. I’m not a very advanced web developer, so if I’m missing something obvious here, my bad. I spent an entire day on this, and can’t seem to find what’s wrong