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, passfalse
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
- Iffalse
the toggle is rendered. If true, it is skipped. The default isfalse
.: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 to2
.:padding
- the space between the border and the thumb. Defaults to2
:thumb_radius
- the radius of the thumb. This determines the size of the entire toggle. Defaults to10
.:compat
- use the pre-v0.11 positioning. The default isfalse
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 isoff
.:text
- the color of the thumb.:thumb
- the color of the track when the toggle ison
.
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
Callback implementation for Scenic.Component.add_to_graph/3
.
Returns a specification to start this module under a supervisor.
Link to this section Functions
Callback implementation for Scenic.Component.add_to_graph/3
.
Returns a specification to start this module under a supervisor.
See Supervisor
.