vwf .

API Reference

Complete API documentation for components, utilities, and framework core

Modal

Flexible modal dialog with glass morphism and keyboard support

🔧 Props

PropertyTypeDefaultDescription
idstringmodalUnique identifier
titlestringundefinedModal title (creates header with close button)
closeFunctionfunctionundefinedFunction to call when closing modal
closeOnBackdropbooleantrueClose modal when clicking backdrop
classstring-CSS classes for modal card

💻 Examples

Simple Modal

const showModal = van.state(false);

return div(
  Button({ onclick: () => showModal.val = true }, 'Open Modal'),
  () => showModal.val ? Modal({
    title: 'Modal title',
    closeFunction: () => showModal.val = false,
  },
    h2({class: 'text-base font-semibold mb-2'}, 'Modal heading'),
    p({class: 'text-sm text-smoke mb-6'}, 'Modal content - Any content can be shownn here'),
    Button({ onclick: () => showModal.val = false }, 'Close')
  ) : ''
);

▶️ 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