# Slab 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](https://github.com/dmiller9911)

> 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](https://give.curemelanoma.org/give/296895/#!/donation/checkout), which funds melanoma research.

## TL;DR

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

## New features

- [Framework types](../get-started.md#typescript): Import `slab-elements/react.js`, `svelte.js` or `vue.js` once, and every tag's properties are checked in your templates.
- [Typed events](../get-started.md#typescript): 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](../get-started.md#frameworks): Importing an element while Next.js, Astro or SvelteKit renders a page on the server no longer throws "window is not defined".
- [Smaller bundles](../get-started.md#import): Elements no longer bundle Slab's whole `package.json` to read their version, which was about 9 KB before compression.
- [Custom states](../components.md): 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](../components/combobox.md): Combobox and Tags Input take `readonly`, as Rating does: the value stays focusable and is submitted, but can't be changed.
- [Validity](../components/slider.md): Slider, Range Slider, Color Picker and Editable have `setCustomValidity()`, `validationMessage` and a `validity-message` part, like the other fields.
- [Opening from code](../components/tooltip.md): Tooltip, Hover Card and Combobox open and close from code without their delays, as Popover and Menu do.
- [Stopping an open](../get-started.md): Every element built on a popover dispatches a cancelable "beforetoggle" before it opens or closes, so an open can be stopped.
- [Toggle events everywhere](../components/dialog.md): Dialog, Alert Dialog, Drawer and Toast dispatch "toggle" too, so every element with `open` has it.
- [Closing like a dialog](../components/dialog.md): Dialog, Drawer, Alert Dialog and Command Palette have `requestClose()`, as a native `<dialog>` does: it dispatches a cancelable "cancel" first.
- [Native events](../components/editable.md): 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](../get-started.md#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](../llms.md): 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](../upgrade.md): 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](../upgrade.md) says what to change for each.

- [Focus rings on Range Slider, Color Picker and Splitter](../upgrade.md#focus-rings)
- [Tooltip and Hover Card's "toggle"](../upgrade.md#toggle)
- [Grid List's selection](../upgrade.md#grid-list)
- [Checkbox Group's values](../upgrade.md#checkbox-group)
- [Password Field's "reveal-change"](../upgrade.md#password-field)
- [Toast's "dismiss"](../upgrade.md#toast)
- [Opening Dialog, Alert Dialog and Command Palette](../upgrade.md#dialog-show)
- [Date Picker's and Date Range Picker's `showPicker()`](../upgrade.md#show-picker)
- [Checkbox's `indeterminate`](../upgrade.md#indeterminate)
- [Subclasses](../upgrade.md#subclasses)

## Upgrade

```sh
pnpm add slab-elements@1.0.0
```
