Scenic v0.10.1 Scenic.Component.Input.Toggle View Source
Add toggle to a Scenic graph.
Data
on?
on?-trueif the toggle is on, passfalseif 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- Iffalsethe 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 Styles
Toggles also honor the following additional styles.
: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.
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
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
Functions
Callback implementation for Scenic.Component.add_to_graph/3
Link to this section Functions
Link to this function
add_to_graph(graph, data \\ nil, opts \\ [])
View Source
add_to_graph(graph, data \\ nil, opts \\ [])
View Source
add_to_graph(graph :: Scenic.Graph.t(), data :: any(), opts :: list()) ::
Scenic.Graph.t()
add_to_graph(graph :: Scenic.Graph.t(), data :: any(), opts :: list()) :: Scenic.Graph.t()
Callback implementation for Scenic.Component.add_to_graph/3.