# Power Button Examples and Reference

### Default Power Button

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

    library(dash)
    library(dashDaq)
    library(dashHtmlComponents)

    app <- Dash$new()

    app$layout(htmlDiv(list(
      daqPowerButton(id = 'my-power-button',
                     on = FALSE),
      htmlDiv(id = 'power-button-output')
    )))

    app$callback(
      output(id = "power-button-output", property = "children"),
      params = list(input(id = "my-power-button", property = "on")),

      update_output <- function(on) {
        return(sprintf("The button is %s", on))
      }
    )

    app$run_server()

The button is False.

### Label

Set the label and label position with `label` and `labelPosition`.

    library(dashDaq)

    daqPowerButton(
        on = TRUE,
        label = "Label",
        labelPosition = "top"
    )

Label

### Size

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

    library(dashDaq)

    daqPowerButton(
        on = TRUE,
        size = 100
    )

### Color

Set the color of the power button with `color`.

    library(dashDaq)

    daqPowerButton(
        on = TRUE,
        color = "#FF5E5E"
    )

## PowerButton Properties

> 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` (character; optional): The ID used to identify this compnent in Dash callbacks.

`on` (logical; default `FALSE`): Whether or not the power button is on.

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

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

`disabled` (logical; optional): If TRUE, power button cannot be clicked.

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

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

`label` is a character | named list with keys:

- `label` (character; optional)

- `style` (named list; optional)

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

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

`style` (named list; optional): Style to apply to the root component element.

`onButtonStyle` (named list; optional): style to apply on switch on button.

`offButtonStyle` (named list; optional): style to apply on switch off button.

`persistence` (logical | character | numeric; 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`.

`persisted_props` (unnamed list of values equal to: 'on'; 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_type` (a value equal to: 'local', 'session' or '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.