Number
<loomi-number> — a themeable number stepper with increment/decrement buttons, min/max/
step enforcement and a floating label. Form-associated.
npm install @loomidev/number litimport "@loomidev/number";Basic Usage
Section titled “Basic Usage”<loomi-number value="1"></loomi-number>Increment/decrement by any step:
<loomi-number step="10" value="0"></loomi-number><loomi-number size="small"></loomi-number><loomi-number size="regular"></loomi-number><loomi-number size="medium"></loomi-number><loomi-number size="big"></loomi-number>Button Transparency
Section titled “Button Transparency”By default the increment/decrement buttons are transparent. Set
transparent-icons="false" for a solid background.
<loomi-number transparent-icons="false"></loomi-number><loomi-number transparent-icons="false" size="big"></loomi-number>Labels
Section titled “Labels”<loomi-number label="Quantity" value="1"></loomi-number>Minimum and Maximum Limits
Section titled “Minimum and Maximum Limits”<loomi-number min="18" max="65" label="Your age" value="18"></loomi-number>The increment/decrement buttons disable at the bounds, and manually typing an out-of-range value clamps it back to the limit on commit.
Decimal Values
Section titled “Decimal Values”<loomi-number with-dots="false" value="3"></loomi-number>Form Values
Section titled “Form Values”<loomi-number name="age" value="18"></loomi-number>new FormData(form).get("age"); // "18"Field appearance
Section titled “Field appearance”Use variant="minimal" for a bottom-border-only field:
<loomi-number label="Quantity" variant="minimal"></loomi-number>Use label-position="inside" to keep a compact label inside the top of the field,
with the number displayed beneath it:
<loomi-number label="Quantity" label-position="inside"></loomi-number>Accessibility
Section titled “Accessibility”For the library-wide baseline, see Foundations — Accessibility.
Responsive behavior
Section titled “Responsive behavior”For the shared container and viewport rules, see Foundations — Responsive behavior.
Dark mode
Section titled “Dark mode”For theme activation, token overrides, and contrast guidance, see Foundations — Dark mode.
Attributes
Section titled “Attributes”| Attribute | Default | Description |
|---|---|---|
name | (blank) | Submitted with the form. |
label | (blank) | Floating label. |
label-position | default | default keeps the floating label; inside keeps a compact label inside the top of the field. |
value | (blank) | Current value (also a property). |
min | 0 | Minimum value. |
max | 100 | Maximum value. |
step | 1 | Increment/decrement amount. |
size | medium | small | regular | medium | big |
variant | default | default | minimal (bottom border only, no box) |
transparent-icons | true | Transparent (vs solid) stepper buttons. (boolean) |
with-dots | true | Allow decimal values. (boolean) |
required | false | Marks the field required. (boolean) |
disabled | false | Disable the control. (boolean) |
no-clearing | false | Remove the default bottom margin. (boolean) |
Methods: focus(). Parts: field, input.
Events
Section titled “Events”| Event | Description |
|---|---|
change | Fired when the value is committed or changed. |
input | Fired while the value is edited. |
Full Example
Section titled “Full Example”<loomi-number name="age" label="Age" size="big" transparent-icons="true" min="18" max="65" step="1" value="18"></loomi-number>Framework integration
Section titled “Framework integration”<loomi-number> is a standard custom element, so the browser can use it 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
Section titled “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/number unless you are editing LoomiUI itself.
cd /path/to/your-appnpm install @loomidev/number 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/componentspnpm --filter @loomidev/number buildpnpm --filter @loomidev/number typecheckChoose your framework
Section titled “Choose 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/lit@3.3.3", "lit/": "https://esm.sh/lit@3.3.3/" } }</script><script type="module" src="https://esm.sh/@loomidev/number"></script>
<loomi-number name="quantity" label="Quantity" min="1" max="10" step="1"></loomi-number>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/number";Because this is a form-capable component, give it a name when it should submit with a native <form>. Read its value with new FormData(form).get("the-name") just like you would for a built-in input.
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-appnpm install @loomidev/number litnpm run devimport "@loomidev/number";<loomi-number name="quantity" label="Quantity" min="1" max="10" step="1"></loomi-number>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/number";
export function LoomiExample() { return ( <loomi-number name="quantity" label="Quantity" min="1" max="10" step="1"></loomi-number> );}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/number";</script>
<template> <loomi-number name="quantity" label="Quantity" min="1" max="10" step="1"></loomi-number></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.
import { CUSTOM_ELEMENTS_SCHEMA, Component } from "@angular/core";import "@loomidev/number";
@Component({ selector: "app-root", standalone: true, schemas: [CUSTOM_ELEMENTS_SCHEMA], template: ` <loomi-number name="quantity" label="Quantity" min="1" max="10" step="1"></loomi-number> `,})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/number";</script>
<loomi-number name="quantity" label="Quantity" min="1" max="10" step="1"></loomi-number>---import "@loomidev/number";---
<loomi-number name="quantity" label="Quantity" min="1" max="10" step="1"></loomi-number>Server-side rendering notes
Section titled “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
Section titled “Dependencies”@loomidev/core@loomidev/theme