Aligning the Dropdown Popup position of a SplitButton to the right

Hi Syncfusion Team,

Currently, the Dropdown Popup of the SplitButton is by default aligned to the left of it.

Image_9920_1696822913281 

However, I want the Dropdown Popup to be aligned to the right of it. Is there a way for me to achieve this?

Image_8595_1696821400910






Thanks.



2 Replies

YA YuvanShankar Arunagiri Syncfusion Team October 10, 2023 11:29 AM UTC

Hi Hung,


Using the open event of split button component, we can customize the popup position show as below.


<SplitButtonComponent id='splitbutton' items={items} content='Save View view' open={onOpen.bind(this)}></SplitButtonComponent>

….

function onOpen(args) {

        var element = document.getElementById('splitbutton').parentElement;

        const rect = element.getBoundingClientRect();

        var left = (rect.left + rect.width) - (rect.left + args.element.clientWidth);

        args.element.parentElement.style.left = `${rect.left + left}px`;

    }


Sample link: https://stackblitz.com/edit/react-hd8kva?file=index.js


Get back to us if you need any further assistance on this.


Regards,

YuvanShankar A



HL Hung Luong October 11, 2023 01:57 PM UTC

Hi YuvanShankar A, 

Thanks for your support.


Loader.
Up arrow icon