alpine vaiables works in scopes trying to call a class outside its scope would not work, and even if u find a way to make it work, i dont think it will give the desired response everytime, does this help?.
@PRESTIGE2930 Previously I achieve this with Javascript without problem. But because I use Laravel livewire with Breeze Starter Kit, the wire:navigate blocks my custom JS that's why I am migrating from Vanilla Javascript to Alpine JS. Some parts like dropdown profile, toggling search bar on click are rewritten in Alpine without problems but this part (the one who originated my request) is a bit hard.