What's new
1.2.0
Date Time Field with time zones, row selection in Table, currency and unit formats in Number, unavailable days in Calendar, and class-only imports.
1.2.0 brings a new component, Date Time Field, for a date and time in a time zone the person can pick. Three features that used to take script of your own come with it. Tables select rows, with a check box in each and one for them all. Number shows money, percents and units, and reads them back as numbers. Calendar keeps weekends and booked days from being picked, shows more than one month, and Date Picker and Date Range Picker pass both on. Every element can now be imported without registering it, and the docs open any example in StackBlitz. It's a minor release, so nothing needs changing.
- 1 new components
TL;DR The short version
- Date Time Field is a native
datetime-localinput with a select of time zones beside it, and submits both. - Table selects rows:
selectablefor one,multiplefor more, a check box in each row, and "change" withselectedRows. - Number takes
format-options,Intl.NumberFormat's options, and shows "$1,234.50", "15%" or "40 km/h" whilevaluestays a number. - Calendar's
isDateUnavailablekeeps days such as weekends from being picked, andmonthsshows several side by side. - Date Picker and Date Range Picker pass
monthsandisDateUnavailableto their Calendar. slab-elements/<name>.class.jsexports an element without registering it, for tags of your own, scoped registries, or two versions of Slab on one page.- Every example opens in StackBlitz, Get started has an import map for a page with no build step, and a new guide animates opening and closing.
- Nothing to change: it's all additions, and styles that select Calendar's parts work as before.
New components
Every one is live below, styled the way this site styles them.
-
In the job site's time zone. Trucks leave the plant an hour before. Date Time Field
A native
Docs for Date Time Fielddatetime-localinput, with a select of time zones beside it, each with its offset at the value's date.valuestays the input's wall-clock time, the time zone is submitted undertime-zone-name, andvalueAsDateis the moment they make together.
Rows you can select
Until now, a Table that selected rows was a Checkbox in each, a name for every one, and a select-all kept in step by hand. Now it's an attribute. selectable allows one row, and multiple more than one, as on Grid List. Each check box is named by its row's header, so a screenreader hears "Select Garage" rather than a column of "checkbox, not checked". It's still a table, read rather than moved through with the arrow keys, so text in it can be selected and links in it work as they do.
const table = document.querySelector('slab-table');
const all = table.querySelector('slab-table-head slab-checkbox');
const boxes = [...table.querySelectorAll('slab-table-body slab-checkbox')];
const sync = () => {
const checked = boxes.filter((box) => box.checked).length;
all.checked = checked === boxes.length;
all.indeterminate = checked > 0 && checked < boxes.length;
};
all.addEventListener('change', () => {
for (const box of boxes) {
box.checked = all.checked;
}
sync();
});
for (const box of boxes) {
box.addEventListener('change', sync);
}
<slab-table aria-label="Pours" multiple>
<slab-table-head>…</slab-table-head>
<slab-table-body>
<slab-table-row selected>…</slab-table-row>
<slab-table-row>…</slab-table-row>
<slab-table-row disabled>…</slab-table-row>
</slab-table-body>
</slab-table>
-
Slab Yards Crew Garage 18 North Driveway 12 North Patio 8 South Footings 6 Poured Select a few, or all
Check a row, or the head row for every one. Check one and Shift-click another to select the rows between. The poured slab is
disabled, so selecting every row leaves it out.index.html <slab-table aria-label="Pours" multiple> <slab-table-head> <slab-table-row> <slab-table-column-header>Slab</slab-table-column-header> <slab-table-column-header>Yards</slab-table-column-header> <slab-table-column-header>Crew</slab-table-column-header> </slab-table-row> </slab-table-head> <slab-table-body> <slab-table-row selected> <slab-table-cell row-header>Garage</slab-table-cell> <slab-table-cell>18</slab-table-cell> <slab-table-cell>North</slab-table-cell> </slab-table-row> <slab-table-row> <slab-table-cell row-header>Driveway</slab-table-cell> <slab-table-cell>12</slab-table-cell> <slab-table-cell>North</slab-table-cell> </slab-table-row> <slab-table-row> <slab-table-cell row-header>Patio</slab-table-cell> <slab-table-cell>8</slab-table-cell> <slab-table-cell>South</slab-table-cell> </slab-table-row> <slab-table-row disabled> <slab-table-cell row-header>Footings</slab-table-cell> <slab-table-cell>6</slab-table-cell> <slab-table-cell>Poured</slab-table-cell> </slab-table-row> </slab-table-body> </slab-table> -
Crew Lead North Sam South Ana One at a time
selectablewithoutmultipleallows one row. Checking another unchecks the first, and there's no select-all.index.html <slab-table aria-label="Crews" selectable> <slab-table-head> <slab-table-row> <slab-table-column-header>Crew</slab-table-column-header> <slab-table-column-header>Lead</slab-table-column-header> </slab-table-row> </slab-table-head> <slab-table-body> <slab-table-row> <slab-table-cell row-header>North</slab-table-cell> <slab-table-cell>Sam</slab-table-cell> </slab-table-row> <slab-table-row> <slab-table-cell row-header>South</slab-table-cell> <slab-table-cell>Ana</slab-table-cell> </slab-table-row> </slab-table-body> </slab-table> -
What was picked
The Table dispatches "change" when the user changes the selection.
selectedRowsare the selected body rows, in order, andselectedRowis the first.index.js const table = document.querySelector('slab-table'); table.addEventListener('change', () => { const slabs = table.selectedRows.map( (row) => row.querySelector('[row-header]').textContent, ); console.log(slabs); // ["Garage", "Patio"] });
Money, percents and units
A native number input can't show a currency symbol or a unit, so a price was a Text Field and a parser of your own, with stepping, min and max left to you. Now Number takes format-options, the options Intl.NumberFormat takes, and shows its value formatted in the page's language. It reads what's typed back, so "$1,234.50", "1234.5" and "1,234.5" are all 1234.5. value and what the form submits stay a plain number, and min, max, step and their validity are a number input's own.
const field = document.querySelector('slab-text-field');
const format = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
});
field.addEventListener('change', () => {
const value = Number(field.value.replace(/[^\d.-]/g, ''));
field.value = Number.isNaN(value) ? '' : format.format(value);
});
// …and min, max, step, the arrow keys and a number
// for the form are yours to do too.
<slab-number
format-options='{"style":"currency","currency":"USD"}'
label="Price per yard"
min="0"
name="price"
step="0.01"
value="165"
></slab-number>
-
Currency
Type "1234.5" or "$1,234.50" and leave the field, and it shows "$1,234.50". The arrow keys step by a cent.
index.html <slab-number format-options='{"style":"currency","currency":"USD"}' label="Price per yard" min="0" step="0.01" value="165" ></slab-number> -
Percent
A percent's value is a fraction, as
Intlformats one, so this field'svalueis 0.15. It steps by 1% unlessstepsays otherwise.index.html <slab-number format-options='{"style":"percent"}' label="Overage" max="1" min="0" value="0.15" ></slab-number> -
Units
Any unit
Intlknows, short or spelled out, such as yards or kilometers per hour.index.html <slab-number format-options='{"style":"unit","unit":"kilometer-per-hour"}' label="Truck speed limit" min="0" value="40" ></slab-number> -
In your language
The format follows the nearest
lang, so in German this is "1.234,50 €", and "1.234,5" is read back as 1234.5.index.html <div lang="de"> <slab-number format-options='{"style":"currency","currency":"EUR"}' label="Preis" min="0" step="0.01" value="1234.5" ></slab-number> </div>
Calendars that know what's booked
min and max kept days out of reach, but only at the ends. A weekend or a day that's already booked could be picked, and the best you could do was undo it on "change". Now isDateUnavailable says which days can't be picked. They can still be focused, so the arrow keys move across them as across any other, and they're aria-disabled for screenreaders. With range, a range can't span one. And months shows more than one month, for a range that runs across two. Date Picker and Date Range Picker take both too.
const calendar = document.querySelector('slab-calendar');
calendar.addEventListener('change', () => {
const day = new Date(calendar.value).getUTCDay();
if (day === 0 || day === 6) {
// It was picked, and shown as picked. Now take it back,
// and tell the user why.
calendar.value = '';
}
});
<slab-calendar months="2" range></slab-calendar>
<script type="module">
const booked = new Set(['2026-12-09', '2026-12-10']);
document.querySelector('slab-calendar').isDateUnavailable = (date) => {
const day = new Date(date).getUTCDay();
return day === 0 || day === 6 || booked.has(date);
};
</script>
-
Two months, weekdays only
The snippet above, live. Weekends and the two booked days can't be picked, and once a range is started, it can't run past a booked day.
index.html <slab-calendar months="2" range value="2026-12-14/2026-12-18" ></slab-calendar> <script type="module"> const booked = new Set(['2026-12-09', '2026-12-10']); document.querySelector('slab-calendar').isDateUnavailable = (date) => { const day = new Date(date).getUTCDay(); return day === 0 || day === 6 || booked.has(date); }; </script> -
In a picker
Date Picker and Date Range Picker pass
monthsandisDateUnavailableto their Calendar. Open this one, and weekends are out.index.html <slab-date-range-picker end-label="Latest" label="Pour window" months="2" start-label="Earliest" ></slab-date-range-picker> <script type="module"> const weekend = (date) => [0, 6].includes(new Date(date).getUTCDay()); document.querySelector('slab-date-range-picker').isDateUnavailable = weekend; </script> -
Laying out the months
Each month has its own grid in
::part(month), inside::part(months), so they can sit side by side, wrap, or stack. Unavailable days are::part(unavailable).index.css slab-calendar::part(months) { display: flex; flex-wrap: wrap; gap: 1.5rem; } slab-calendar::part(unavailable) { text-decoration: line-through; }
Also new
-
Selecting rows
A
selectableormultipleTable starts each body row with a native check box, named "Select" and the row's header. Withmultiple, the head row selects them all, and Shift with a click selects a range. -
Currency, percent and unit
Number formats its value with
format-optionsin the language of the nearestlang, and reads what's typed back. Text that isn't a number isbadInput, "Enter a number." -
Unavailable days
isDateUnavailableis a function of a day that returnstruefor one that can't be picked. It can still be focused, it'saria-disabledand::part(unavailable), and a range can't span it. -
More than one month
monthsshows that many months side by side, each with its own grid and::part(month-heading), laid out with::part(months)and::part(month). -
In the pickers
Date Picker and Date Range Picker take
monthsandisDateUnavailableand pass them to their Calendar, and export its new parts. -
Class-only imports
Every element has a class module beside its registering one, such as
slab-elements/tabs.class.js. It exports the same class and registers nothing, not even its parts, so the tag names and the registry are yours. Import from it to subclass, too. -
Open in StackBlitz
Each component page opens its example, styled or as it ships, in StackBlitz, to change it and watch it run.
-
No build step
Get started has an import map that loads Slab and Lit from a CDN, so the same imports work in a plain HTML file.
-
Animate opening and closing
A new guide animates popovers, dialogs, disclosures and toasts on their
openstate, closing as well as opening, and keeps it gentle for someone who asks for less motion.
Upgrade
pnpm add slab-elements@1.2.0
Every change, in full, is in the release notes.