You want to make a high-fidelity prototype. And you want to make it quickly. It should be easy to share, suitable for usability testing on multiple devices (responsive), and allow for real interactions and animations.
A Figma or Sketch prototype doesn't feel real enough. There are all sorts of interactions and logic in the product. You want to be able to add an element into the page flow (e.g. push other items downwards), without creating hacks and dozens of artboards for each little variation.
You want to give your users real form controls to test out your design.
Other prototyping tools such as Framer are useful for page transitions and interactions. But these tools fall short for getting user input.
Apps such as Webflow are an option for creating web-based prototypes with real interactions. But with Webflow you're learning the tool rather than how to code. This might work for some people, but I prefer to use the tools of the web – HTML, CSS and Javascript. There are also other reasons I prefer working in my code editor – for example, you can pull in CSS directly from your design system or production app.
Make a code-based prototype! It'll be responsive, interactive and realistic. Real enough to feel like you're interacting with the real product. It'll be better than whatever else you were going to do.
You might be a HTML and CSS guru. If so, coding a page layout is your bread and butter. And yet the JavaScript interactions always slow you down. JavaScript isn't your strong suit, and that's OK. But it stops you from really feeling productive in code.
I just want to make a hamburger menu open and close when the user clicks it!
Dropdowns, modals, hamburger menus, tabs. The building blocks of modern app UIs. These are frustratingly slow to prototype and iterate on using traditional design tools.
But you can easily make these interactive in Javascript for your code-based prototypes. Yep, even if you think you suck at it.
I've used all of the above, and none of them felt right for rapid prototyping. I want to get interactions working quickly so I can get back to focusing on the design problems.
Alpine JS is a small JavaScript library that's perfect for designers making prototypes.
A rugged, minimal framework for composing JavaScript behavior in your markup – Alpine docs
With Alpine, you create your JavaScript behavior right in your HTML. Perfect for interactive elements where you're generally toggling classes to show and hide elements on the page.
Some benefits to Alpine over the common alternatives like React or Vue:
Add the following script to the end of your <head>
section of your HTML page.
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
That's it. It will initialize itself.
The CodePen examples use Bulma for styling. Bulma doesn't have any JavaScript, so it's perfect for trying out Alpine JS. Most of this markup is straight Bulma, with some Alpine JS added to make it work!
The Bulma dropdown docs explain that the dropdown menu wrapping div
needs a class of is-active
when the menu is open. We can use Alpine to do this.
x-data="{ open: false }"
. Open is set to false as the default. This means the menu will be closed when the page loads. x-bind:class="{ 'is-active': open }"
means that when the state is changed to open
, the class is-active
should be applied.open
. This is done with x-bind:class="{ 'is-active': open }" @click="open = true"
.@click.away="open = false"
.And that's it. Add a few Alpine statements to your HTML and you've got an interactive element.
Below is a CodePen with three interactions:
See if you can find the Alpine JS parts to understand how each of the three items works.
Feel free to fork this example and play around with it! You could try and integrate more of the Bulma components with Alpine!
Give Alpine JS a shot next time you want to make a code-based prototype with realistic interactions. It's easy to use, which gives you the freedom to experiment.
You might fall in love with the power and simplicity it can give you.