Skip to content

DocsGet startedFrameworks

PT

Get started

Frameworks

The same base runs in plain HTML and has official adapters for React, Vue, Nuxt, Svelte, Angular and Astro.

One base, many adapters

The base is a set of 33 <u-*> custom elements that runs on any page with JavaScript: plain HTML, PHP, Django, Rails, WordPress. On top of it sit official adapters, with TypeScript types, for React (Next and Vite), Vue, Nuxt, Svelte (SvelteKit), Angular and Astro.

The names are the same everywhere: USankey, USlider, USelect. The adapter only translates props, events and when the element gets registered. The component logic stays in the base.

Which package and how to wire it

FrameworkPackageValueEventsSSR
React, Next@leallabs/unslop-reactvalue + onChangeonChange, onApply, onReadyYes
Vue@leallabs/unslop-vuev-model@u-changeYes
Nuxt@leallabs/unslop-nuxtv-model@u-changeYes
Svelte, SvelteKit@leallabs/unslop-sveltebind:valueonChangeYes
Angular@leallabs/unslop-angularngModel or formControl(u-change)Yes
Astro@leallabs/unslop-astroInitial value onlyaddEventListener("u-change")Yes
Plain HTMLNone: unslop.css and unslop.elements.jsvalueaddEventListener("u-change")Doesn't apply

The adapter lists @leallabs/unslop as a peer and npm installs it along. In Astro it's optional, so it goes in the same command. The <u-*> elements and define() come from that package; without a build, unslop.elements.js from the CDN defines the same <u-*>. The older unslop.js still works, with data-u and the u:change event.

One example in each

Each example binds a slider to a value and puts a bar list inside a card. The snippets come from the repo fixtures, which pass the test suite.

Install

npm install @leallabs/unslop-react

CSS and registration

CSS: once, at the root. In Next it goes in app/layout.tsx; in Vite, in main.tsx.

import "@leallabs/unslop/css";

Example

Example (from fixtures/vite-react/src/Demo.tsx and fixtures/next/components/Demo.tsx). In Next, the file starts with "use client".

import { useState } from "react";
import { USlider, UBarlist } from "@leallabs/unslop-react";

const periods = [{
  label: "Today", total: 120,
  items: [{ label: "/docs", value: 80 }, { label: "/blog", value: 40 }],
}];

export default function Dashboard() {
  const [level, setLevel] = useState(2);
  return <>
    <USlider min={0} max={4} value={level} label="Effort" onChange={(e) => setLevel(e.detail.value)} />
    <UBarlist card label="Views" periods={periods} />
  </>;
}

What differs between them

  • Angular has no card. The chart frame is written by hand, because generating it outside would break hydration.
  • Astro only has the initial value. There's no reactive state on the server; you read changes through the event.
  • Vue and Angular listen to u-change. change would collide with the native event of the inner input.

How this is tested

On every release, each adapter runs in a real framework fixture and goes through server rendering, hydration, events, value and memory leaks.

Type to search. Arrows pick, Enter opens.