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.
If you'd like to remember Doug too, please consider a donation to the Melanoma Research Alliance, which funds melanoma research.
- 15 new features
- 10 changes to check
TL;DR The short version
- Every event is typed in React, Vue, Svelte and plain TypeScript, down to its
detail. - Each custom state is in
custom-elements.jsonwith a description, so:state()selectors are documented beside parts and attributes. readonly, the validity API,show()andhide(), and a cancelable "beforetoggle" are on every element they make sense for.- Every element with
opendispatches "toggle" as aToggleEventand matches:state(open). - 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.jsorvue.jsonce, and every tag's properties are checked in your templates. -
Typed events
The JSX, Vue and Svelte types include an
onprop for each event, andSlabElementEventsmaps each element to its events foraddEventListener. -
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.jsonto 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 doescustom-elements.json. Every element withopenmatches:state(open), and every one withdisabledmatches: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(),validationMessageand avalidity-messagepart, 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
openhas 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
@deprecatednote 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.
- Focus rings on Range Slider, Color Picker and Splitter
- Tooltip and Hover Card's "toggle"
- Grid List's selection
- Checkbox Group's values
- Password Field's "reveal-change"
- Toast's "dismiss"
- Opening Dialog, Alert Dialog and Command Palette
- Date Picker's and Date Range Picker's `showPicker()`
- Checkbox's `indeterminate`
- Subclasses
Upgrade
pnpm add slab-elements@1.0.0
Every change, in full, is in the release notes.