Web Awesome Components in BetterForms
Use Web Awesome components inside BetterForms with self-contained bfcomponents that lazy-load the library and styles.
Approach
Component Definition: wa_button
wa_button{
"name": "wa_button",
"schema": {
"label": "Button",
"variant": "brand",
"size": "medium"
},
"html": "<wa-button :variant=\"schema.variant || 'brand'\" :size=\"schema.size || 'medium'\" @click=\"namedAction('onClick')\">{{ schema.label || 'Button' }}</wa-button>",
"namedActions": {
"onBeforeMount": [{
"action": "function",
"function": "try {\n // Load Web Awesome loader (dist-cdn) and default theme CSS once per app session\n await BF.libraryLoadOnce('https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3/dist-cdn/webawesome.loader.js');\n await BF.libraryLoadOnce('https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3/dist/styles/themes/default.css', { type: 'stylesheet' });\n} catch (error) {\n console.error('Web Awesome load failed:', error);\n BF.errorThrow(10500, 'Web Awesome load failed', (error && error.message) || String(error));\n}"
}],
"onClick": [{
"action": "showAlert",
"options": { "text": "wa_button clicked", "type": "information" }
}]
}
}Usage on a Page
Alternative: Global Project Script (CDN Kit)
Troubleshooting
Next Steps
See Also
Last updated
Was this helpful?