Nutrient Web SDK
    Preparing search index...

    Namespace UI

    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.

    Here's how to pass a slot configuration to fully replace the comment thread UI:

    NutrientViewer.load({
    // ... Your configuration.
    ui: {
    commentThread: (instance, id) => {
    return {
    render: (params) => {
    const div = document.createElement("div");

    // Return a DOM Node.
    return div;
    },
    };
    },
    },
    });

    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.

    Usage of lifecycle methods - onMount and onUnmount

    NutrientViewer.load({
    // ... Your configuration.
    ui: {
    commentThread: (instance, id) => {
    const div = document.createElement("div");

    return {
    render: (params) => {
    // Return a DOM Node.
    div.innerText = `This is a custom UI for the comment thread`;
    return div;
    },
    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.
    },
    };
    },
    },
    });

    Interfaces

    Configuration

    Type Aliases

    CommentThreadUI
    CommentUI
    SidebarUI
    SlotConfiguration
    SlotConfigurationCallback