How do I map an external sheet style?

I have a css called styles in my static folder

styles.css

and this is how I call in my script the css

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

how do I map this style.css to the external_stylesheets? (I need to do this)

Hi @topotaman

If you place styles.css in a folder called assets dash will automatically include it. Note that you also need to include __name__ when you instantiate the app:

app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP,dbc.icons.BOOTSTRAP])

See more info here:

I know dash works with the static foldier… but this q is because I deployed the app in the web, and need to map the css (and dont know how to map it in dash)

You can directly map the url in the external_stylesheets section. Hopefully this will solve the issue for you.

@jinnyzor hi, can you do an example please? (this might be usefull for others)

Sure thing.

app = dash.Dash(name, external_stylesheets=[dbc.themes.BOOTSTRAP,dbc.icons.BOOTSTRAP, ‘http://linktoyourstylesheet’])

You can also do the same thing with external scripts.

thanks, good idea

works! check out my web app www.pokerutils.com

2 Likes
  1. Start with an HTML file that contains an embedded style sheet, such as this one.
  2. Create a new file and save it as StyleSheet.
  3. Move all the CSS rules from the HTML file to the StyleSheet.
  4. Remove the style block from the HTML file.

Thanks