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

Add toggle to a Scenic graph.

data

Data

on?

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

styles

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-options

Additional Options

Toggles also honor the following additional options.

  • :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.
  • :compat - use the pre-v0.11 positioning. The default is false

theme

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

Usage

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

examples

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

Functions

Returns a specification to start this module under a supervisor.

Link to this section Functions

Link to this function

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

View Source

Callback implementation for Scenic.Component.add_to_graph/3.

Returns a specification to start this module under a supervisor.

See Supervisor.