UIToggle

Create a simple toggle component

Since: 6.5.0 (4.9.0)

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

disabled

boolean

false

Wether the toggle is disabled or not

tabIndex

number

Apply specific tab index

size

string

"normal"

Normal

Small

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