UIToggle

Create a simple toggle component

Since: 7.0.0 (4.9.0)

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

icon

string

Icon name from style-guide. Example arrow-right-bold (or (Deprecated) FontAwesome 4 icon. Example fa-user). Prefix text

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