Toggle

A toggle with an attribute active that can either be true or false, to enable or disable properties of an interactive plot.

using GLMakie
fig = Figure()

ax = Axis(fig[1, 1])

toggles = [Toggle(fig, active = active) for active in [true, false]]
labels = [Label(fig, lift(x -> x ? "$l visible" : "$l invisible", t.active))
    for (t, l) in zip(toggles, ["sine", "cosine"])]

fig[1, 2] = grid!(hcat(toggles, labels), tellheight = false)

line1 = lines!(0..10, sin, color = :blue, visible = false)
line2 = lines!(0..10, cos, color = :red)

connect!(line1.visible, toggles[1].active)
connect!(line2.visible, toggles[2].active)

fig

Attributes

active

Defaults to false

Indicates if the toggle is active or not.

alignmode

Defaults to Inside()

The align mode of the toggle in its parent GridLayout.

buttoncolor

Defaults to COLOR_ACCENT[]

The color of the toggle button.

cornersegments

Defaults to 15

The number of poly segments in each rounded corner.

framecolor_active

Defaults to COLOR_ACCENT_DIMMED[]

The color of the border when the toggle is hovered.

framecolor_inactive

Defaults to RGBf(0.94, 0.94, 0.94)

The color of the border when the toggle is inactive.

halign

Defaults to :center

The horizontal alignment of the toggle in its suggested bounding box.

height

Defaults to 18

The height of the toggle.

rimfraction

Defaults to 0.33

The border width as a fraction of the toggle height

tellheight

Defaults to true

Controls if the parent layout can adjust to this element's height

tellwidth

Defaults to true

Controls if the parent layout can adjust to this element's width

toggleduration

Defaults to 0.15

The duration of the toggle animation.

valign

Defaults to :center

The vertical alignment of the toggle in its suggested bounding box.

width

Defaults to 32

The width of the toggle.