Slab
Slab

What's new

1.0.0

A stable API: typed events for every framework, custom states in the manifest, and validity, read-only fields and opening from code where they were missing.

1.0.0 adds no components. It fills the gaps between the ones there are, so each attribute, method and event works the same way wherever it appears, and it settles the API: from here, nothing is removed without a deprecation first. It's a major release, with a few changes to check before you upgrade.

In memory of Doug Miller

This 1.0 release is dedicated to my childhood friend, Doug Miller. We were friends for 30 years. He got me into web development and open source software. He lost his battle with melanoma last year. Today is his birthday. So I dedicate this to him. Rest in peace, buddy. I love and miss you.

Tony Ward

If you'd like to remember Doug too, please consider a donation to the Melanoma Research Alliance, which funds melanoma research.

TL;DR The short version

  1. Every event is typed in React, Vue, Svelte and plain TypeScript, down to its detail.
  2. Each custom state is in custom-elements.json with a description, so :state() selectors are documented beside parts and attributes.
  3. readonly, the validity API, show() and hide(), and a cancelable "beforetoggle" are on every element they make sense for.
  4. Every element with open dispatches "toggle" as a ToggleEvent and matches :state(open).
  5. Nothing goes away without a deprecation first, and a deprecated API lasts until the next major version.

New features

  • Framework types

    Import slab-elements/react.js, svelte.js or vue.js once, and every tag's properties are checked in your templates.

  • Typed events

    The JSX, Vue and Svelte types include an on prop for each event, and SlabElementEvents maps each element to its events for addEventListener.

  • Imports on a server

    Importing an element while Next.js, Astro or SvelteKit renders a page on the server no longer throws "window is not defined".

  • Smaller bundles

    Elements no longer bundle Slab's whole package.json to read their version, which was about 9 KB before compression.

  • Custom states

    Each component's page lists its :state()s in a table beside its parts, and so does custom-elements.json. Every element with open matches :state(open), and every one with disabled matches :state(disabled).

  • Read-only fields

    Combobox and Tags Input take readonly, as Rating does: the value stays focusable and is submitted, but can't be changed.

  • Validity

    Slider, Range Slider, Color Picker and Editable have setCustomValidity(), validationMessage and a validity-message part, like the other fields.

  • Opening from code

    Tooltip, Hover Card and Combobox open and close from code without their delays, as Popover and Menu do.

  • Stopping an open

    Every element built on a popover dispatches a cancelable "beforetoggle" before it opens or closes, so an open can be stopped.

  • Toggle events everywhere

    Dialog, Alert Dialog, Drawer and Toast dispatch "toggle" too, so every element with open has it.

  • Closing like a dialog

    Dialog, Drawer, Alert Dialog and Command Palette have requestClose(), as a native <dialog> does: it dispatches a cancelable "cancel" first.

  • Native events

    Editable dispatches "input" before "change", like every other field, and the 25 form controls that validate list their "invalid" event in the types and the manifest.

  • Deprecations

    How an API goes away after 1.0: a @deprecated note in the types and the manifest, a badge in these docs, and a minor release or more before the next major removes it.

  • Agent skill

    The package includes a skill that teaches coding agents to use Slab the native way, with a reference for every component built from the manifest. Add it with npx skills add ynotdraw/slab-elements --skill slab.

  • Upgrade to 1.0

    Every change since 0.1 that can break something, in one guide, with what to change for each.

Before you upgrade

10 changes can break what you have. They're why this is a major release. Upgrade to 1.0 says what to change for each.

Upgrade

Install
pnpm add slab-elements@1.0.0

Every change, in full, is in the release notes.