Hi all,
Iโm working on a design system and trying to create an interactive side navigation menu using component variants + a shared variable (selectedItem). Each nav item has two variants: default and selected.
Hereโs what Iโve set up:
-
Each menu item has a
labelproperty (e.g., "Dashboard", "Settings", etc.) -
On click, the interaction sets the variable:
selectedItem = "Settings" -
Then I added conditional logic:
โโข IfselectedItem == "Settings"โ switch toselected
โโข Else โ switch todefault
๐ฏ Goal: When one nav item is selected, all other items should revert to default โ only one selected item at a time.
โ Issue: Only the clicked item changes. The rest donโt respond to the variable update.
โ
I even tried using While value of variable changes or placing the logic in each itemโs On Click โ still not getting the expected behavior.
๐ What am I missing? How can I ensure all nav items reactively update based on the selectedItem variable?
This is for a reusable side nav component in my design system, so it needs to be scalable.
Any guidance, working examples, or best practices would be super helpful. ๐
