@@ -74,7 +74,7 @@ These attributes control various aspects of the form’s behavior and appearance
7474* ` language ` (optional): Default language for the builder.
7575* ` translation-languages ` (optional): Comma-separated list of allowed languages.
7676* ` base-url ` (optional): The base URL of your Aidbox instance.
77- * ` style ` (optional): Custom styling for the iframe.
77+ * ` style ` (optional): Custom styling applied to both iframe and loader container .
7878* ` config ` (optional): The [ configuration] ( configuration.md ) as a JSON string.
7979* ` theme ` (optional): Theme settings as a JSON string.
8080* ` token ` (optional): JWT token for authentication.
@@ -87,7 +87,7 @@ These attributes control various aspects of the form’s behavior and appearance
8787* ` hide-footer ` (optional): Hides the form footer.
8888* ` hide-language-selector ` (optional): Hides language selector.
8989* ` base-url ` (optional): The base URL of your Aidbox instance.
90- * ` style ` (optional): Custom styling for the iframe.
90+ * ` style ` (optional): Custom styling applied to both iframe and loader container .
9191* ` config ` (optional): The [ configuration] ( configuration.md ) as a JSON string.
9292* ` theme ` (optional): Theme settings as a JSON string.
9393* ` token ` (optional): JWT token for authentication.
@@ -352,13 +352,15 @@ Below is a list of events you can listen for:
352352* ` back ` : Emitted when the back button is clicked.
353353* ` save ` : Emitted when the form is saved.
354354* ` select ` : Emitted when an item is selected.
355+ * ` loading ` : Emitted when loading state changes. ` event.detail.loading ` is ` true ` during load and ` false ` when done.
355356* ` ready ` : Emitted when the builder is loaded.
356357{% endtab %}
357358
358359{% tab title="Renderer" %}
359360* ` change ` : Triggered when the questionnaire response is updated.
360361* ` submit ` : Emitted when the Submit button is clicked.
361362* ` extracted ` : Emitted when data extraction occurs.
363+ * ` loading ` : Emitted when loading state changes. ` event.detail.loading ` is ` true ` during load and ` false ` when done.
362364* ` ready ` : Emitted when the renderer is loaded.
363365{% endtab %}
364366{% endtabs %}
@@ -394,3 +396,51 @@ Below is an example of how to listen for `change` event:
394396```
395397{% endtab %}
396398{% endtabs %}
399+
400+ ### Step 5: Optional Custom Loading Content
401+
402+ Both web components support a ` loading ` slot.
403+ Put your spinner, skeleton, or any custom HTML inside this slot to display it while the iframe is loading and SWM handshake is in progress.
404+ The component ` style ` attribute is applied to both iframe and loader container.
405+
406+ {% tabs %}
407+ {% tab title="Builder" %}
408+ ``` html
409+ <aidbox-form-builder
410+ id =" aidbox-form-builder"
411+ style =" width : 100% ; height : 640px ; border : none ; display : flex "
412+ form-id =" {{ FORM_ID }}"
413+ >
414+ <div slot =" loading" >Loading builder...</div >
415+ </aidbox-form-builder >
416+ ```
417+ {% endtab %}
418+
419+ {% tab title="Renderer" %}
420+ ``` html
421+ <aidbox-form-renderer
422+ id =" aidbox-form-renderer"
423+ style =" width : 100% ; height : 640px ; border : none ; display : flex "
424+ questionnaire-id =" {{ ID }}"
425+ >
426+ <div slot =" loading" >Loading form...</div >
427+ </aidbox-form-renderer >
428+ ```
429+ {% endtab %}
430+ {% endtabs %}
431+
432+ You can also observe loading state with events:
433+
434+ ``` html
435+ <script >
436+ const builder = document .getElementById (' aidbox-form-builder' );
437+
438+ builder .addEventListener (' loading' , (event ) => {
439+ console .log (' Loading state:' , event .detail .loading ); // true | false
440+ });
441+
442+ builder .addEventListener (' ready' , () => {
443+ console .log (' Builder is ready' );
444+ });
445+ </script >
446+ ```
0 commit comments