Power Button Examples and Reference


Default Power Button

An example of a default power button without any extra properties.

import dash
from dash.dependencies import Input, Output
import dash_daq as daq
import dash_html_components as html

app = dash.Dash(__name__)

app.layout = html.Div([
    daq.PowerButton(
        id='my-power-button',
        on=False
    ),
    html.Div(id='power-button-output')
])


@app.callback(
    Output('power-button-output', 'children'),
    Input('my-power-button', 'on')
)
def update_output(on):
    return 'The button is {}.'.format(on)


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

Label

Set the label and label position with label and labelPosition.

import dash_daq as daq

daq.PowerButton(
    on='True',
    label='Label',
    labelPosition='top'
)

Size

Adjust the size (diameter in pixels) of the power button with size.

import dash_daq as daq

daq.PowerButton(
    on='True',
    size=100
)

Color

Set the color of the power button with color.

import dash_daq as daq

daq.PowerButton(
    on='True',
    color='#FF5E5E'
)

Power Button Properties

Access this documentation in your Python terminal with:
```python

help(dash_daq.PowerButton)
```

Our recommended IDE for writing Dash apps is Dash Enterprise’s
Data Science Workspaces,
which has typeahead support for Dash Component Properties.
Find out if your company is using
Dash Enterprise
.

id (string; optional):
The ID used to identify this compnent in Dash callbacks.

className (string; optional):
Class to apply to the root component element.

color (string; optional):
The indicator color to display when power button is on.

disabled (boolean; optional):
If True, power button cannot be clicked.

label (dict; optional):
Description to be displayed alongside the button. To control
styling, pass an object with label and style properties.

label is a string | dict with keys:

  • label (string; optional)

  • style (dict; optional)

labelPosition (a value equal to: ‘top’, ‘bottom’; default 'top'):
Where the button label is positioned.

on (boolean; default False):
Whether or not the power button is on.

persisted_props (list of a value equal to: ‘on’s; default \['on'\]):
Properties whose user interactions will persist after refreshing
the component or the page. Since only on is allowed this prop
can normally be ignored.

persistence (boolean | string | number; optional):
Used to allow user interactions in this component to be persisted
when the component - or the page - is refreshed. If persisted is
truthy and hasn’t changed from its previous value, a value that
the user has changed while using the app will keep that change, as
long as the new value also matches what was given originally.
Used in conjunction with persistence_type.

persistence_type (a value equal to: ‘local’, ‘session’, ‘memory’; default 'local'):
Where persisted user changes will be stored: memory: only kept in
memory, reset on page refresh. local: window.localStorage, data is
kept after the browser quit. session: window.sessionStorage, data
is cleared once the browser quit.

size (number; default 48):
The size (diameter) of the power button in pixels.

style (dict; optional):
Style to apply to the root component element.

theme (dict; default light):
Theme configuration to be set by a ThemeProvider.