UI Namespace contains all the types related to UI Customization API.
With UI Customization API you can:
Fully replace the default component UI — for example, the comment thread — with your own.
Insert a custom UI at a predefined slot in an existing component — for example, a custom header in the comment thread.
Replace an existing slot in a component with your own custom UI — for example, replace the default editor in the comment thread with your own UI.
The UI customization API is largely enabled through the concept of slots. These are passed to the SDK as part of load configuration using the ui property when initializing the SDK.
Think of slots as predefined placeholders in the Web SDK UI where you can place your custom UI.
Slots configuration are passed in the ui property.
The ui configuration accepts configuration for all supported slots.
To provide a custom UI, a slot accepts a function that returns an object with a render method, and the render method should return a DOM Node.
Example
Here's how to pass a slot configuration to fully replace the comment thread UI:
In addition to the render method, you can also define lifecycle methods in the object returned by the function.
These methods enable you to perform actions at specific points in the component’s lifecycle.
They’re also useful for effects such as adding event listeners or performing cleanup.
return { render: (params) => { // Return a DOM Node. div.innerText=`This is a custom UI for the comment thread`; returndiv; }, onMount: (id) => { console.log(`Comment thread mounted with id: ${id}`); // You can add event listeners or perform other setup actions here. }, onUnmount: (id) => { console.log(`Comment thread unmounted with id: ${id}`); // You can remove event listeners or perform other cleanup actions here. }, }; }, }, });
UI Namespace contains all the types related to UI Customization API.
With UI Customization API you can:
The UI customization API is largely enabled through the concept of slots. These are passed to the SDK as part of load configuration using the ui property when initializing the SDK. Think of slots as predefined placeholders in the Web SDK UI where you can place your custom UI. Slots configuration are passed in the
uiproperty. Theuiconfiguration accepts configuration for all supported slots.To provide a custom UI, a slot accepts a function that returns an object with a render method, and the render method should return a DOM Node.
Example
Here's how to pass a slot configuration to fully replace the comment thread UI:
In addition to the
rendermethod, you can also define lifecycle methods in the object returned by the function. These methods enable you to perform actions at specific points in the component’s lifecycle. They’re also useful for effects such as adding event listeners or performing cleanup.See
Refer to the UI Customization Guide for more details.
Example
Usage of lifecycle methods -
onMountandonUnmount