English · Français
CSS flexbox layout for 4D forms, written in plain 4D v21 code.
AJUI_flex is a 4D component (project mode) that implements the layout algorithm of the W3C CSS Flexible Box Layout Module Level 1 and applies it to the objects of a 4D form. You describe a container and its items the way you would in CSS (direction, wrap, justify, align, gap, grow, shrink…), and AJUI_flex moves and resizes the form objects. No plug-in, no web area.
Case of
: (FORM Event.code=On Load)
Form.flex:=cs.flex.FlexLayout.new("box"; "item_"; {wrap: "wrap"; justifyContent: "space-between"; alignItems: "center"; gap: 8; padding: 10})
Form.flex.item("item_3").grow:=1
Form.flex.apply()
: (FORM Event.code=On Resize)
Form.flex.apply()
End case - Complete flexible-length resolution (§9.7): grow, shrink weighted by basis, min/max clamping with freezing, factor sums below 1.
direction,wrap(includingwrap-reverse),justifyContent,alignItems,alignSelf,alignContent,gap/rowGap/columnGap,padding,margin,order.automargins on both axes (push a button to the right withmargin: {left: "auto"}).- Percentages (
"25%") for basis, width/height, min/max, margins, padding and gaps. - Nested flex containers: an item with
childrenis itself a flex container, sized to its content, and the whole tree is laid out in one call. - Optional
minWidth/minHeight: "auto"(content-based minimum size). - A pure computation engine (
FlexEngine) with no form commands, usable for printing, SVG or anything that needs rectangles, and a form adapter (FlexLayout).
| 0.1.0 (single-level flexbox) | Validated in 4D v21: FlexEngine_runFixture 1105/1105, demo OK. |
| 0.2.0 (auto margins, %, nesting) | Validated against Google Chrome through mini4d, a small interpreter that runs the actual .4dm source (2342/2342 cases). Not yet run in 4D itself. |
See Compatibility for details.
- Getting started: installation as a component, first layout
- API reference:
FlexEngine,FlexLayout - Properties: supported properties compared with CSS
- Examples: toolbar, wrapping grid, nested layout, percentages
- Demos
- FlexGuide: interactive guide to the supported properties (
FlexLayout_guide, five languages) - Reducing the footprint: options to shrink the built component (guide only, nothing implemented)
- Testing: Chrome-measured fixture, mini4d
- Benchmark
- Limitations: differences from CSS
- Compatibility
- Changelog
Project/ 4D project (the component itself: classes, methods, forms)
Resources/fixtures/ reference fixture used by FlexEngine_runFixture
docs/en, docs/fr documentation
tests/ mini4d interpreter and test scripts (Python)
tools/ generators and checker of the FlexGuide form and its translations (Python)
tests/tools/ fixture generation and Chrome measurement (Node.js)
The repository root is the component root: clone it next to your host project and declare it in
dependencies.json (see Getting started).
Source code comments and the demo forms are in French.
Maurice Inzirillo, AJAR S.A.
MIT © 2026 Maurice Inzirillo / AJAR S.A.