vwf .

API Reference

Complete API documentation for components, utilities, and framework core

Reference/API/Toggle

Toggle

Toggle switch with moving dot animation

🔧 Props

PropertyTypeDefaultDescription
idstringtoggle-{timestamp}Unique identifier
labelstringundefinedLabel text
checkedState|booleanfalseCurrent state
onchangefunctionundefinedChange handler
messageobjectundefinedValidation message
containerClassstring-Container classes (vwfcolor, vwfsize)

🎨 Utility Classes

PatternDescription
vwfcolor-{color}Sets toggle color
vwfsize-{size}Controls toggle size

💻 Examples

Simple Toggle

const enabled = van.state(false);
return Toggle({
  label: 'Enable notifications',
  checked: enabled,
  onchange: (e) => enabled.val = e.target.checked
});

▶️ Live Preview

💡 Click "Edit Code" to modify the example

🔄 Click "Apply Changes" to see your modifications

↩️ Click "Reset" to restore original code

💡 Usage Tips

🔗 Related

Explore vwf

Discover what vwf can do