Skip to main content

A base component library for Dash applications

Project description

Dash BaseComponent

A BaseComponent class for building modular Plotly Dash apps.

See this article for more info.

Installation

To install the dash-basecomponent package, use the following command:

pip3 install dash-basecomponent

Usage

To use these components in your own Dash application, simply import the component you want to use and add it to your application's layout.

For example:

from dash import Dash, html, callback
from dash_basecomponent import BaseComponent as bc

class Counter(html.Div, bc):
    def __init__(self, **kwargs):
        super().__init__([
            html.Button("Increment", id=self.child_id("button")),
            html.Span("0", id=self.child_id("count"), style={"marginLeft": "10px"}),
        ], **kwargs)
    
    @callback(
        bc.ChildOutput("count", "children"),
        bc.ChildInput("button", "n_clicks"),
        prevent_initial_call=True
    )
    def increment_count(n_clicks):
        return str(n_clicks)

app = Dash(__name__)
app.layout = Counter()

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

Examples

The examples directory contains several example applications that demonstrate how to use these components.

  • hello_world.py: An example application that uses the InputCombiner and ExpandContract components.
  • tic_tac_toe.py: An example application that uses the Game component.
  • snake.py: An example application that uses the SnakeGameBoard component.
  • example.py: An example application that uses the Counter component.

Contributing

Contributions to this project are welcome. If you have a new component you'd like to add, or if you've found a bug in one of the existing components, please submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dash_basecomponent-0.1.4.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dash_basecomponent-0.1.4-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file dash_basecomponent-0.1.4.tar.gz.

File metadata

  • Download URL: dash_basecomponent-0.1.4.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for dash_basecomponent-0.1.4.tar.gz
Algorithm Hash digest
SHA256 995f3302d28c4b58137442660bd7fa2bcfc2ac46182b28c17f95c6f3f905c772
MD5 e6a7277762f2c063c7c3d1a42d899bdf
BLAKE2b-256 a07e64625db332d7c5f580f51c7c292cc580fe7a80cd85681064ea8412fdd2ea

See more details on using hashes here.

File details

Details for the file dash_basecomponent-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for dash_basecomponent-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cdc06d63f2a9746fcee00197ae7fa1ea24322e13797864a4b63ecdcb2fef67c2
MD5 14dac68aada81b31104273f8f9462146
BLAKE2b-256 79db19a701665764448dc9450c17631a25e694a8a4b4310a8c1633b5f56829b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page