Softypo / themes

CSS themes for Dash Bootstrap Components & JSON themes for Plotly graphs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

themes provider

CSS themes for Dash Bootstrap Components & JSON themes for Plotly graphs
View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

Product Name Screen Shot

(back to top)

Getting Started

Simply use jsdeliver to get the files from this repository into your dash app.

Prerequisites

  • dash
    pip install dash
  • dash bootstrap components
    pip install dash-bootstrap-components

Usage

For server side loading:

# To use different themes,  just change the link:
themes = 'https://cdn.jsdelivr.net/gh/Softypo/themes/_dark/bootstrap_darkly.min.css'

# initial config
app = dash.Dash(__name__, external_stylesheets=[themes, title='Your Dashboard Name')

For client side loading, a "client side callback" is required:

#client side python callback portion:
app.clientside_callback(
    ClientsideFunction(
        namespace="dashboard",
        function_name="theme_switcher",
    ),
    Output("theme_provider", "theme"), #Output can be hidden div component
    Input("themeToggle", "value"), #switch component that you need to declare in your app body.
)
//client side javascript callback portion:
window.dash_clientside = Object.assign({}, window.dash_clientside, {
    dashboard: {
        theme_switcher: function (themeToggle, themes) {
            const stylesheet = document.querySelector('link[rel=stylesheet][href^="https://cdn.jsdelivr"]');
            let light = 'https://cdn.jsdelivr.net/gh/Softypo/themes/_light/bootstrap_united.min.css'
            let dark = 'https://cdn.jsdelivr.net/gh/Softypo/themes/_dark/bootstrap_darkly.min.css'
            let themeLink = themeToggle ? light : dark;
            setTimeout(function () { stylesheet.href = themeLink; }, 100);
            if (themeToggle) return { "colorScheme": "light" };
            else return { "colorScheme": "dark" };
        },
    }
});

(back to top)

Roadmap

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Softypo

Project Link: https://github.com/Softypo/themes

(back to top)

Acknowledgments

(back to top)

About

CSS themes for Dash Bootstrap Components & JSON themes for Plotly graphs