How to set dynamic height in the widget element

How to set dynamic height in the widgets.

Is there any way to fix the height based on the review content?

Code is:

If I configured 700px height

<div

className="trustpilot-widget"

ref={trustBoxRef}

id="trustbox"

data-locale={locale}

data-template-id={pdpTrustpilotId}

data-businessunit-id={trustpilotBuId}

data-style-height="700px"

data-style-width="100%"

data-theme="light"

data-sku={sku}

data-review-languages="en"

data-star-color="#000000"

data-text-color="#1B1B21"

data-no-reviews="show"

data-fullwidth="true"

></div>

If I set auto in the below props

data-style-height="auto"
 
Then scroll appear inside the widget.

Was this post helpful?

1 comment

Sort by
  • Avatar

    Michael Cohen Trustpilot

    Hi Mohan K,

     

    There is currently no way to have the height of the iframe adjust to review content automatically. Our typical recommendation here is to use a slightly smaller height for the widget (eg. 450-550px) to help balance the white space.

     

    Other more custom solutions require either creating an "Expand" button below the widget to toggle the CSS of the iframe with a larger height, or you could use our APIs to check the review count/length and set a dynamic height to the widget that way.

     

    Cheers,

    Michael  

     

    -1
Please sign in to leave a comment.