Scenic.Component.Input.Toggle (Scenic v0.10.3) View Source

Add toggle to a Scenic graph.

Data

on?

  • on? - true if the toggle is on, pass false if not.

Styles

Toggles honor the following styles. The :light and :dark styles look nice. The other bundled themes...not so much. You can also supply your own theme.

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

Additional Styles

Toggles also honor the following additional styles.

  • :border_width - the border width. Defaults to 2.
  • :padding - the space between the border and the thumb. Defaults to 2
  • :thumb_radius - the radius of the thumb. This determines the size of the entire toggle. Defaults to 10.

Theme

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

  • :border - the color of the border around the toggle
  • :background - the color of the track when the toggle is off.
  • :text - the color of the thumb.
  • :thumb - the color of the track when the toggle is on.

Optionally, you can supply the following entries:

  • :thumb_pressed - the color of the thumb when pressed. Defaults to :gainsboro.

Usage

You should add/modify components via the helper functions in Scenic.Components

Examples

The following example creates a toggle.

graph
|> toggle(true, translate: {20, 20})

The next example makes a larger toggle.

graph
|> toggle(true, translate: {20, 20}, thumb_radius: 14)

Link to this section Summary

Link to this section Functions

Link to this function

add_to_graph(graph, data \\ nil, opts \\ [])

View Source

Specs

add_to_graph(graph :: Scenic.Graph.t(), data :: any(), opts :: list()) ::
  Scenic.Graph.t()

Callback implementation for Scenic.Component.add_to_graph/3.