Welcome To Mini

Mini lets you add interactivity to your web apps without leaving your HTML.

Mini is currently in Alpha. While we don't anticipate any major API changes, there are several known issues, including a relatively large file size (80kb gzipped). We're actively working on improvements and don't expect to release a beta version until 2025.

Getting Started

To add Mini to your project, simply save this file to your codebase and load it when your page loads.

<script src="/mini.js" ></script>

Alternatively you can also load Mini directly from our CDN if you prefer.

<script src="https://cdn.mini-js.com/1.0.15.js" ></script>

What can Mini do?

Mini is an extremely easy to use way to add UI Behaviour to your web software. It's not designed to store all of your state — for example it doesn't include routing or authentication — so it works best when paired with a Server-side Rendered approach.

The best way to understand where Mini shines is to see some examples.

Add classes to elements when clicked

  • Simple Dropdown Menu: "When a user clicks the button, add some classes to the arrow icon, and the hidden div that holds the menu."
<button :click="showMenu = !showMenu" :clickout="showMenu = false">
  <div :class="showMenu ? 'rotate-180' : '' " ></div>
  Show Menu
<div :class="showMenu ? 'transform opacity-100 scale-100' : 'transform opacity-0 scale-95 pointer-events-none' "></div>
  • Simple Flight Picker: "When a user clicks the button, add some classes to the hidden flight picker div, and remove them from other divs."
> 11 years
2 to 11 years
2 years

Learn Mini (in Three Steps)

1. Prefix your html attributes with : to let them evaluate javascript

For example, for form inputs, use :value to set an input's value.

<input type="text" :value="window.navigator.userAgent" />

This will display this ⤵

  • To set an element's class, use the :class attribute
  • To set an element's style, use the :style attribute
  • And so on...

2. Use vanilla javascript variables to store state

Variables default to the global namespace, so you can define your data anywhere in your page and use it later.

<input type="text" :value="firstName + ` ` +lastName" />

This will display this ⤵

3. Use events to respond to user interactions.

Mini extends the browser's native events with shorthand attributes like :click, :change, :press, :clickout and a few others. For example, you can use the:click attribute to respond to elements being clicked

<button :click="firstName = 'Pamela'" />
<button :click="lastName = 'Halpert'" />
<input type="text" :value="firstName + ` ` +lastName"  />

Combine these patterns 👆 for infinite possibilities

Being able to set state using javascript variables, update state in response to interactions, and mutate the dom depending on the state, unlocks a lot of UI patterns.

More Mini

Now that you've learned the basics, here are a few more tricks you can use.

Use :text to set the inner text of an element

<span :text="`My lucky number is: `+Math.floor(Math.random() * 100) + 1;" />

This will display:

Use :change to monitor form inputs, and this.value to get their values

<input type="text" :change="firstName=this.value" />
<span :text="`Your first name is: ` + firstName">
Your first name is:

Use event to get the current event

You can also access the current event with the event keyword.

<button :click="console.log(event)">Click Me</button>

Use :each to loop through arrays or objects

While we don't recommend storing deep state, we do provide the ability to iterate through and display collections of objects, like so.

  todos = [
    { name: "Clean Dishes",  complete: true },
    { name: "Vacuum Floors", complete: false}
<div :each="todo in todos">
  <div :text="todo.name"></div>

Use :load to execute code when an element is loaded

Sometimes we want code to be executed as soon as the page, or a specific element on the page, is loaded.

<div :load="console.log('I was loaded')"></div>

This is also useful when looping through arrays with :each.


We often need to group together elements which draw from the same state. To do this, first we add the :scope attribute to the outer HTML element, then we prefix our variables with scope..

<div :scope>
  <button :click="scope.showDropdown = true">First Dropdown</button>
  <div :class="scope.showDropdown ? 'block' : 'hidden'"></div>
<div :scope>
  <button :click="scope.showDropdown = true">Second Dropdown</button>
  <div :class="scope.showDropdown ? 'block' : 'hidden'"></div>

We can also set the default values within a scoped group when they load.

<div :scope="showDropdown=true">
  <button :click="scope.showDropdown = true">First Dropdown</button>
  <div :class="scope.showDropdown ? 'block' : 'hidden'"></div>

Use el. to scope state to a specific dom element

The benefit of scope is that you can have groups of dom elements that all share state. But sometimes your state only needs to exist on a single element. In this case you can use the el. prefix before your variables.


It's Just Javascript

The basic premise of Mini is to let attributes execute javascript. This means you can do anything javascript can do, including, for example:

Basic, If Else statements

  :class="if (selectedTab === 'when') {
            'bg-white shadow-lg'
          } else {

Nested Ternaries

  :class="(selectedTab === 'When' ? 'bg-white shadow-lg' : 'hover:bg-gray-300')
          (whenSelectedTab === 'Dates' ? 'hidden' : '')"


Because javascript is quite verbose, putting it inside of our attributes can get unwieldy quickly. So we added some helper methods that make doing common things like setting timeouts and working with arrays, a little more tidy.

Use await wait() instead of setTimeout()

<button :click="alert('Starting');await wait(3000);alert('Ended')">

Use Array helpers to filter and manipulate data

  filteredFruits = fruits
<input type="text" :change="filteredFruits = fruits.search(this.value);">
<div :each="fruit in filteredFruits">
  <div :text="fruit"></div>

See all the custom methods in the Reference here.

Keyboard Events

For keyboard events, you can listen to them using :keyup, :keydown, and :keypress:

<input type="text" :keyup="console.log(event)" />

You can also do cool stuff like chaining keyboard modifiers together. See The Reference for more info.