· via Hacker News – Front Page (native)
Uniform swaps browser layout and rendering for WASM and WebGPU in a 280 KB toolkit
A toolkit shared on Hacker News ships a full WASM layout engine, text layout, and WebGPU renderer in under 280 KB compressed, replacing the browser's native UI pipeline.
A UI stack that skips the browser
Uniform, an open-source project published on GitHub under rkaehn/uniform and surfaced on Hacker News's front page as a Show HN post, replaces the browser's built-in text, layout, and rendering with its own implementation. According to the project's documentation, a complete web application built on the library compresses to under 280 KB, a figure that includes the toolkit's text engine, layout solver, and GPU renderer combined.
The core is written in C, with shaders in the Slang shading language. On the web, that core compiles to WebAssembly and draws through WebGPU. On iOS and macOS it runs as native code and renders via Metal.
Layout, text, and shapes
The layout system merges two techniques. Constraints are expressed between a parent and a child by pinning an anchor on the child to an anchor on the parent, plus an optional offset. Stacks handle spacing, padding, alignment, and distribution, and each child can fill the available space, hug its content, or hold a fixed size.
Layout calculations run in fixed-point arithmetic, and edges snap to pixel boundaries to keep alignment and spacing crisp. Text layout exposes character-level information, so an application can build its own selection behavior or per-character effects, and font, size, weight, and color can vary across ranges within a single string.
Rendering is organized around signed distance fields, where every pixel knows its distance to the nearest edge plus the corresponding normal. The documentation credits this with enabling refraction near edges in glass-like materials, blur that varies across a shape, realistic shadows, and shapes that blend into each other. Rounded rectangles use curves that are continuous in position, slope, curvature, and the rate of change of curvature, and those curves morph smoothly into pills and circles; they are also available for arbitrary polylines and polygons.
There are no prebuilt components. Buttons are built from scratch, and for harder pieces like scrolling lists and text fields the library supplies the internals, such as event handling, gestures, physics, and animation, while the developer reads the computed results and draws the visuals.
Input and display
Input is handled through a platform-independent layer covering touch, stylus, keyboard, and mouse, with raw events hit-tested against the node hierarchy. A gesture system lets components negotiate which one acts, and the bundled gestures, including tap, long-press, pan, and pinch, are written against the same public API a developer would use, so custom gestures have equal standing.
The renderer supports extended dynamic range: values above 1.0 for colors, gradients, and images render brighter on capable displays. The compositor can work at high bit depth or apply dithering, and high refresh rates are supported.
Two APIs over one C core
A JavaScript API is tuned for iteration: no build step, changes visible immediately, calling straight into the C core. A C API offers more performance, supports static linking, and compiling the library from source, shaders included, takes under a second.
For packaged apps, the runtime executes JavaScript through JavaScriptCore, JIT-compiled on desktop and interpreted on mobile, and a runtime plus a single application file can be bundled for distribution, app stores included. On the web, no runtime is needed because the library ships directly with the page. C projects get headers and a binary archive per platform, and the application and its server can be merged into one dependency-free executable, making a production update a matter of copying a file.
Preview status
Uniform is currently a preview: the API may change and some features are unfinished. iOS, macOS, and the web are supported today; Windows, Linux, and Android are planned, rendering via Vulkan.
Why it matters
Uniform claims the whole UI stack, layout, text, and GPU rendering together, fits in under 280 KB compressed, a payload smaller than the JavaScript of many production websites. That compactness, combined with fixed-point layout and pixel snapping under the toolkit's control, is the pitch for interfaces that render identically everywhere and sidestep the browser's cross-platform rendering differences.
Because the library ships with the application rather than with the platform, improvements reach all users immediately instead of waiting on browser or operating system release cycles. The trade-offs are real: leaving the DOM forfeits the semantics, accessibility tree, and developer tooling that browsers provide by default, and the project's documentation does not currently address accessibility. The WebGPU requirement also narrows the set of browsers that can run these apps. Even so, as a demonstration of how far WebAssembly plus a modern graphics API can carry a UI, it is a notable data point for anyone watching the boundary between web and native applications.
- #webassembly
- #webgpu
- #ui-toolkit
- #open-source
- #javascript