In this episode, we focus on building a site selector dropdown in our dashboard, which will let users easily switch between their different sites or add a new one. We start by integrating the floating-vue
package to give us a slick dropdown experience, and walk through how to install and set it up in our Vue (with Inertia) project.
We work right inside the app's JavaScript entry points and components, showing you where to import the plugin and its styles, and then wire it up as a Vue plugin. Then, we create a reusable SiteSelector
component, making it super easy to drop the site selector wherever we want in our app.
After that, we build out the markup for the dropdown button and its menu, using Tailwind classes for styling and pulling in some SVG icons for that polished feeling. We initially hardcode a couple of sites in the dropdown to get the structure and styling just right, including making the links Inertia-friendly using their Link
component.
We also add a button at the bottom to "Add a Site" — this is where users will eventually open a modal to create a new site. Don’t worry, we only make things look and feel right for now.
Next, we wire things up to the backend: we pass the real list of sites to the Vue component as a prop, iterate over it, and make sure each site in the dropdown links to the right dashboard page. We show you how to tweak the URLs, use site IDs, and update the UI instantly.
By the end of the episode, you’ll have a fully working site selector dropdown that’s flexible, reusable, and looks great. Next, we’ll look at how API resources can help keep your data clean and manageable!