Mini is an incredibly simple way to add lightweight frontend state to your web pages and apps. It works great for ui components and form fields, where you want to change element classes or input values on user interaction.
Add mini to your codebase directly from the CDN.
<ui-state> element<ui-state>
<div></div>
</ui-state>
Now you can build hundreds of interactive UI components without leaving your HTML.
| Update The Dom | Use With | |
|---|---|---|
| ui-text | Sets the inner text of an element | <div>, <span>, <p>, etc. |
| ui-value | Sets the value of a form input or textarea | <input>, <select>, <textarea>, etc. |
| ui-checked | Sets a checkbox or radio button state |
<input type="checkbox">, <input type="radio"> |
| ui-class | Sets the class of an element | <div>, <span>, <p>, etc. |
| ui-data-[key] | Set a data attribute | <div>, <span>, <p>, etc. |
| ui-aria-[key] | Set an aria attribute | <div>, <span>, <p>, etc. |
| ui-[key] | Set any attribute | Any element you like |
| Respond To User Interaction | |
|---|---|
| ui-change | Use on form elements to listen for changes in their value. |
| ui-click | Triggered when the element is clicked. |
| ui-clickme | Triggered when the element is clicked, but not if the click is on a child element. |
| ui-clickout | Triggered when a click happens outside of the element. |
| ui-focus | Triggered when an input or textarea is focused. |
| ui-blur | Triggered when an input or textarea is blurred. |
Mini.js started out as a library. But as we iterated, we realized that our patterns mapped almost perfectly to the web component standard. So we did what any good library author does, and we rewrote it. This gives us...
ui-change to monitor form inputs, and this.value to get their valuesYour first name is:
ui-change to listen for the select change.event to get the current eventYou can also access the current event with the event keyword.
ui-load to execute code when an element is loadedSometimes we want code to be executed as soon as the page, or a specific element on the page, is loaded.
<ui-state>
<div ui-load="console.log('I was loaded')"></div>
</ui-state>
Browsers already have events for all of the most common user interactions. Mini just makes it easier to use them to update the DOM.
What other libraries are similar to Mini?
The most well known library that bears similarity with Mini is Alpine.js. We both set out to solve a similar problem, but with slightly different approaches. There are also several others - the best list is maintained at unsuckjs.com.
When Should I Use Mini?
Use Mini when you want to add sprinkles of behaviour or interactivity patterns to your app, which would be otherwise unwieldy to add using vanilla javascript, but where a full-fledged framework like React would be overkill.
When Should I Not Use Mini?
Mini isn't designed for working with object-based state - for example, looping through and rendering thousands of items in an array onto the page.
Who Made Mini Js?
Mini js was an internal project from Really Good Software, a remote software development agency. Most of the spec was done by Tony (@tonyennis), and most of the code was written by Joeylene (@jorenrui).