@loomidev/listview
v0.3.0
Published
<loomi-listview>/<loomi-listview-item> — a divided list.
Maintainers
Readme
@loomidev/listview
<loomi-listview> — a divided list of <loomi-listview-item> rows. It mimics
<ul><li>: the component only draws the dividing lines between items — what goes
inside each row is entirely up to you.
npm install @loomidev/listview litimport "@loomidev/listview";Basic Usage
Each <loomi-listview-item> is a flex container, so laying out an avatar next to text
is just a couple of child elements.
<loomi-card no-padding>
<loomi-listview>
<loomi-listview-item>
<loomi-avatar size="small" image="/me.jpg"></loomi-avatar>
<div>
<div style="font-weight:500">Alex R. Bennett</div>
<div style="font-size:0.875rem;opacity:0.7">[email protected]</div>
</div>
</loomi-listview-item>
<loomi-listview-item>
<loomi-avatar size="small" label="AJ" bg-color="warning"></loomi-avatar>
<div>
<div style="font-weight:500">Anonymous Jackson</div>
<div style="font-size:0.875rem;opacity:0.7">[email protected]</div>
</div>
</loomi-listview-item>
</loomi-listview>
</loomi-card>Transparent Background
By default the list sits on a white background. Remove it to drop the list onto whatever background color you set on a parent element instead.
<loomi-listview transparent style="background:#fefce8">
<loomi-listview-item>Item one</loomi-listview-item>
<loomi-listview-item>Item two</loomi-listview-item>
</loomi-listview>Compact Spacing
Tightens the gap between rows — useful for dense sidebars or dropdown-style lists.
<loomi-listview compact>
<loomi-listview-item>Notifications</loomi-listview-item>
<loomi-listview-item>Messages</loomi-listview-item>
<loomi-listview-item>Settings</loomi-listview-item>
</loomi-listview>Accessibility
For the library-wide baseline, see Foundations — Accessibility.
Responsive behavior
For the shared container and viewport rules, see Foundations — Responsive behavior.
Dark mode
For theme activation, token overrides, and contrast guidance, see Foundations — Dark mode.
Attributes
<loomi-listview>
| Attribute | Default | Description |
| ------------- | ------- | ---------------------------------------- |
| transparent | false | Remove the white background. (boolean) |
| compact | false | Reduce row padding. (boolean) |
Slots
| Slot | Description | | ----------- | ------------------------------------ | | (default) | Content placed inside the component. |
Full Example
<loomi-listview compact transparent style="background:#fefce8">
<loomi-listview-item>
<loomi-avatar size="small" image="/me.jpg"></loomi-avatar>
<div>
<div style="font-weight:500">Alex R. Bennett</div>
<div style="font-size:0.875rem;opacity:0.7">[email protected]</div>
</div>
</loomi-listview-item>
</loomi-listview>Framework integration
<loomi-listview-item> and <loomi-listview> are standard custom elements, so the browser can use them in plain HTML, Blade, React, Vue, Angular, Svelte, Astro, and most other frameworks. The important beginner rule is: install the package, import it once before the tag is rendered, then write the Loomi tag in your template.
Where to run commands
Run install commands from the app where you want to use this component. That means the folder that contains that app's package.json. Do not run these install commands from packages/listview unless you are editing LoomiUI itself.
cd /path/to/your-app
npm install @loomidev/listview litIf you are contributing to LoomiUI itself, first move to the top-level components folder. That is where the main package.json for all packages lives, and pnpm --filter ... commands should be run from there:
cd /path/to/your-copy-of-loomiui/components
pnpm --filter @loomidev/listview build
pnpm --filter @loomidev/listview typecheckChoose your framework
Use the CDN version for prototypes, documentation pages, or a quick reproduction. The import map tells the browser where to find Lit, which Loomi components use internally.
<script type="importmap">
{ "imports": { "lit": "https://esm.sh/[email protected]", "lit/": "https://esm.sh/[email protected]/" } }
</script>
<script type="module" src="https://esm.sh/@loomidev/listview"></script>
<loomi-listview compact>
<loomi-listview-item>Profile updated</loomi-listview-item>
<loomi-listview-item>Payment received</loomi-listview-item>
</loomi-listview>In Vite, Webpack, Parcel, Rollup, or a framework build pipeline, install the package and import it once in your main app JavaScript file. After that, you can use the Loomi tag anywhere in your app.
import "@loomidev/listview";Run the install command from your Laravel project root, then import the component in resources/js/app.js. If your project uses Laravel Vite, npm run dev and npm run build should also be run from the Laravel project root.
cd /path/to/your-laravel-app
npm install @loomidev/listview lit
npm run dev// resources/js/app.js
import "@loomidev/listview";<loomi-listview compact>
<loomi-listview-item>Profile updated</loomi-listview-item>
<loomi-listview-item>Payment received</loomi-listview-item>
</loomi-listview>React can render Loomi tags directly. If you are on React 18, or if you need to pass arrays, objects, or functions, use a ref and assign those values after the component mounts.
import "@loomidev/listview";
export function LoomiExample() {
return (
<loomi-listview compact>
<loomi-listview-item>Profile updated</loomi-listview-item>
<loomi-listview-item>Payment received</loomi-listview-item>
</loomi-listview>
);
}If TypeScript does not recognize the Loomi tag in JSX, add it to your app's JSX type declarations.
Import the package in the component that uses it, or once in your main Vue file. Vue templates can use Loomi tags directly. For arrays, objects, or functions, pass the value as a JavaScript property instead of as plain text.
<script setup>
import "@loomidev/listview";
</script>
<template>
<loomi-listview compact>
<loomi-listview-item>Profile updated</loomi-listview-item>
<loomi-listview-item>Payment received</loomi-listview-item>
</loomi-listview>
</template>If Vue warns that the tag is an unknown component, configure compilerOptions.isCustomElement for tags that start with loomi- in your Vite or Vue config.
Import the package once and tell Angular to allow custom HTML tags with CUSTOM_ELEMENTS_SCHEMA. For NgModule apps, add the schema to the module instead of the standalone component.
// app.component.ts
import { CUSTOM_ELEMENTS_SCHEMA, Component } from "@angular/core";
import "@loomidev/listview";
@Component({
selector: "app-root",
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<loomi-listview compact>
<loomi-listview-item>Profile updated</loomi-listview-item>
<loomi-listview-item>Payment received</loomi-listview-item>
</loomi-listview>
`,
})
export class AppComponent {}Svelte can import the package inside a component script. Astro can import it in the frontmatter of the page or layout where the tag appears.
<script>
import "@loomidev/listview";
</script>
<loomi-listview compact>
<loomi-listview-item>Profile updated</loomi-listview-item>
<loomi-listview-item>Payment received</loomi-listview-item>
</loomi-listview>---
import "@loomidev/listview";
---
<loomi-listview compact>
<loomi-listview-item>Profile updated</loomi-listview-item>
<loomi-listview-item>Payment received</loomi-listview-item>
</loomi-listview>Server-side rendering notes
Frameworks such as Next.js, Nuxt, SvelteKit, and Astro sometimes render HTML on the server before browser-only code runs. If your framework complains, move the Loomi import to client-side code. In Next.js, that usually means a component with "use client"; in Nuxt, it often means a .client.ts plugin.
Dependencies
@loomidev/core
