Introduction
ui4html
brings layout to the HTML, close to the element definitions. It is a good fit if you want
to create a web-based app UI quickly and intuitively, as opposed to finessing the look and feel
of an HTML document.
ui4html
gives you “strict flexibility”. UI elements are placed strictly (“Place this element
below that one”) but flexibly (“And keep it there when it moves”).
Here’s the code from the video above, and some highlighted ui4html
features:
<div fit="true" dock="center">
<input placeholder="Username" dock="topleft">
<input placeholder="Password" dock="previous.below">
<button id="login" dock="previous.below"
click="error.top=login.bottom:0.3s">
Login
</button>
<div id="error" center="login.center" layer="lower">
Check username
</div>
</div>
- Placing an element relative to the containing element:
dock="topleft"
,dock="center"
- Placing an element relative to a peer element:
dock="previous.below"
- Leaving a standard gap between the elements
- Sizing an element based on the space required for the children:
fit="true"
- Controlling the “layer” or z-index of an element:
layer="lower"
- Changing the layout in reaction to an event:
click="error.top..."
- Animating the changes in the layout:
error.top=login.bottom:0.3s
Getting started
Include the latest version of ui4.js
on your page from the CDN with:
<script src="https://unpkg.com/ui4html"></script>
Or fixed to a specific version:
<script src="https://unpkg.com/ui4html@0.8.0/dist/ui4.js"></script>
Documentation
Dig deeper in these sections:
- Basics cover element placement on the page.
- Page layouts can be made more responsive with conditions and layouts.
- There is some support for animations.
- Developer usability is making sure that things work as you expect.
- Reference has everything listed.
- Notes on similar packages in other environments can be found in research.
Simple samples
- Calculator - may look familiar, and demonstrates a boring but flexible way of placing semi-repetitive elements in a grid.
- Lorem Picsum browser - using images from the excellent Lorem Picsum service, demonstrates resizing the whole layout with the size of the screen.
To do
Conditions- Text sizing
- Animation with right/bottom
Grids and aspect ratios- Open-ended grids
- Side menu sample
- Docs: Reactive
- Docs: Animation
- Docs: Reference