UIToggle

Create a simple toggle component

Properties

Name

Type

Default

Description

id

string

Required - Id of the toggle

label

string

Required - The text label

alignRight

boolean

false

Set to true to have label place to the right

checked

boolean

false

Wether the toggle is on or off

onToggle

function

Callback for when the toggle value changes

Example

import {UIToggle} from 'writer'

render($$) {
    const el = $$('div')
    return el.append(
        $$(UIToggle, {
            id: 'mytoggle',
            label: this.getLabel('My toggle'),
            checked: true,
            onToggle: (checked) => {
                // Do something
            }
        })
    )
}

Last updated