cluster-layout
Children in a row that wraps onto more lines when there isn't room: buttons, tags, footer links. justify and align line them up.
This one has no events: it shows what it's given.
Source: cluster-layout.zb, and its registry item.
Install
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/cluster-layout.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/cluster-layout.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/cluster-layout.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/cluster-layout.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/cluster-layout.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/cluster-layout.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/cluster-layout.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/cluster-layout.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/cluster-layout.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/cluster-layout.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/cluster-layout.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/cluster-layout.json
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/cluster-layout.js"></script>The compiled install writes src/components/zubra/cluster-layout.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.
Usage
<cluster-layout gap="0.5rem">
<span class="demo-chip">Baking</span>
<span class="demo-chip">Gardening</span>
<span class="demo-chip">Choir</span>
<span class="demo-chip">Book club</span>
<span class="demo-chip">Walking group</span>
<span class="demo-chip">Quilting</span>
</cluster-layout>
<script type="module">
import './components/zubra/cluster-layout.js';
</script>import './components/zubra/cluster-layout.js';
export function ClusterLayoutExample() {
return (
<cluster-layout gap="0.5rem">
<span className="demo-chip">Baking</span>
<span className="demo-chip">Gardening</span>
<span className="demo-chip">Choir</span>
<span className="demo-chip">Book club</span>
<span className="demo-chip">Walking group</span>
<span className="demo-chip">Quilting</span>
</cluster-layout>
);
}<script setup>
import './components/zubra/cluster-layout.js';
</script>
<template>
<cluster-layout gap="0.5rem">
<span class="demo-chip">Baking</span>
<span class="demo-chip">Gardening</span>
<span class="demo-chip">Choir</span>
<span class="demo-chip">Book club</span>
<span class="demo-chip">Walking group</span>
<span class="demo-chip">Quilting</span>
</cluster-layout>
</template>
<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) --><script>
import './components/zubra/cluster-layout.js';
</script>
<cluster-layout gap="0.5rem">
<span class="demo-chip">Baking</span>
<span class="demo-chip">Gardening</span>
<span class="demo-chip">Choir</span>
<span class="demo-chip">Book club</span>
<span class="demo-chip">Walking group</span>
<span class="demo-chip">Quilting</span>
</cluster-layout>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/cluster-layout.js';
@Component({
selector: 'app-cluster-layout-example',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<cluster-layout gap="0.5rem">
<span class="demo-chip">Baking</span>
<span class="demo-chip">Gardening</span>
<span class="demo-chip">Choir</span>
<span class="demo-chip">Book club</span>
<span class="demo-chip">Walking group</span>
<span class="demo-chip">Quilting</span>
</cluster-layout>
`,
})
export class ClusterLayoutExample {
}API
| Property | Type | Default |
|---|---|---|
gap | string | "0.75rem" |
justify | string | "flex-start" |
align | string | "center" |
| Slot | For |
|---|---|
(default) | The children. |
Size
0.5 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 16.6 KB.