Scenic.Components.checkbox

You're seeing just the function checkbox, go back to Scenic.Components module for more information.
Link to this function

checkbox(graph, data, options \\ [])

View Source

Specs

checkbox(
  source :: Scenic.Graph.t() | Scenic.Primitive.t(),
  data :: {String.t(), boolean()},
  options :: list()
) :: Scenic.Graph.t() | Scenic.Primitive.t()

Add a Checkbox to a graph

Data

{text, checked?}

  • text - must be a bitstring
  • checked? - must be a boolean and indicates if the checkbox is set.

Messages

When the state of the checkbox changes, it sends an event message to the parent scene in the form of:

{:value_changed, id, checked?}

Styles

Buttons honor the following standard styles

  • :hidden - If false the component is rendered. If true, it is skipped. The default is false.
  • :theme - The color set used to draw. See below. The default is :dark

Theme

Checkboxes work well with the following predefined themes: :light, :dark

To pass in a custom theme, supply a map with at least the following entries:

  • :text - the color of the text in the button
  • :background - the background of the box
  • :border - the border of the box
  • :active - the border of the box while the button is pressed
  • :thumb - the color of the check mark itself

Examples

The following example creates a checkbox and positions it on the screen.

graph
|> checkbox({"Example", true}, id: :checkbox_id, translate: {20, 20})