Selection
Combobox
A text input that filters a list of Options as you type, to pick one or, with multiple, several as removable tags.
- Element
<slab-combobox>- Built on
<input role=combobox>
Example
Here's a styled version, <slab-styled-combobox>. It's not
in the package — it's an example of what you can build with the
headless element. Copy it and make it yours at the
bottom of this page. Switch to "As it ships" to see the same markup
with the headless element and no CSS at all. That's your starting
point.
<div class="stack">
<slab-styled-combobox label="Supplier" placeholder="Start typing a name">
<slab-styled-option value="alder">Alder Ready-Mix</slab-styled-option>
<slab-styled-option value="basalt">Basalt Concrete Co.</slab-styled-option>
<slab-styled-option value="cascade">Cascade Aggregates</slab-styled-option>
<slab-styled-option value="delta">Delta Batch Plant</slab-styled-option>
<slab-styled-option value="eagle" disabled>Eagle Rock Materials</slab-styled-option>
</slab-styled-combobox>
<slab-styled-combobox label="Crews" placeholder="Add a crew" multiple>
<slab-styled-option value="north" selected>North Yard</slab-styled-option>
<slab-styled-option value="south">South Yard</slab-styled-option>
<slab-styled-option value="finishers" selected>Finishers</slab-styled-option>
<slab-styled-option value="pump">Pump Truck</slab-styled-option>
<slab-styled-option value="night">Night Pour</slab-styled-option>
</slab-styled-combobox>
</div>
<div class="stack">
<slab-combobox label="Supplier" placeholder="Start typing a name">
<slab-option value="alder">Alder Ready-Mix</slab-option>
<slab-option value="basalt">Basalt Concrete Co.</slab-option>
<slab-option value="cascade">Cascade Aggregates</slab-option>
<slab-option value="delta">Delta Batch Plant</slab-option>
<slab-option value="eagle" disabled>Eagle Rock Materials</slab-option>
</slab-combobox>
<slab-combobox label="Crews" placeholder="Add a crew" multiple>
<slab-option value="north" selected>North Yard</slab-option>
<slab-option value="south">South Yard</slab-option>
<slab-option value="finishers" selected>Finishers</slab-option>
<slab-option value="pump">Pump Truck</slab-option>
<slab-option value="night">Night Pour</slab-option>
</slab-combobox>
</div>
Usage
pnpm add slab-elements lit
import 'slab-elements/combobox.js';
export function MyCombobox() {
return (
<slab-combobox label="Language" name="language">
<slab-option value="en">English</slab-option>
<slab-option value="es">Spanish</slab-option>
<slab-option value="fr">French</slab-option>
</slab-combobox>
);
}
MyCombobox.jsx React 19 or later, which sets props on custom elements as properties.
import 'slab-elements/combobox.js';
import { html, LitElement } from 'lit';
import { customElement } from 'lit/decorators.js';
@customElement('my-combobox')
export class MyCombobox extends LitElement {
render() {
return html`
<slab-combobox label="Language" name="language">
<slab-option value="en">English</slab-option>
<slab-option value="es">Spanish</slab-option>
<slab-option value="fr">French</slab-option>
</slab-combobox>
`;
}
}
my-combobox.ts Slab is built on Lit, so its elements are at home in Lit's templates.
<script setup>
import 'slab-elements/combobox.js';
</script>
<template>
<slab-combobox label="Language" name="language">
<slab-option value="en">English</slab-option>
<slab-option value="es">Spanish</slab-option>
<slab-option value="fr">French</slab-option>
</slab-combobox>
</template>
MyCombobox.vue Let Vue's compiler know slab- tags are custom elements with isCustomElement.
<script>
import 'slab-elements/combobox.js';
</script>
<slab-combobox label="Language" name="language">
<slab-option value="en">English</slab-option>
<slab-option value="es">Spanish</slab-option>
<slab-option value="fr">French</slab-option>
</slab-combobox>
MyCombobox.svelte Svelte binds properties and events to custom elements like any other element.
import 'slab-elements/combobox.js';
export const MyCombobox = <template>
<slab-combobox label="Language" name="language">
<slab-option value="en">English</slab-option>
<slab-option value="es">Spanish</slab-option>
<slab-option value="fr">French</slab-option>
</slab-combobox>
</template>;
MyCombobox.gjs Ember sets attributes, and a dynamic value like {{this.max}} sets the property when the element has one. {{on}} listens for any event by its name.
<script type="module">
import 'slab-elements/combobox.js';
</script>
<slab-combobox label="Language" name="language">
<slab-option value="en">English</slab-option>
<slab-option value="es">Spanish</slab-option>
<slab-option value="fr">French</slab-option>
</slab-combobox>
index.html Any bundler (or an import map) takes care of the imports.
Its Options, and Option Groups, are the same ones Listbox uses.
With multiple, each selected Option is shown before the input as a tag, a button that removes it. Choosing an Option toggles it and leaves the listbox open for the next one. values lists them in the order they were chosen, and each is submitted as its own entry, the way a <select multiple> submits them. removeLabel names the tags’ buttons, “Remove” and the Option’s text by default.
With readonly, the value can’t be changed but the Combobox can still be focused, read and submitted, where disabled leaves it out of the form. The listbox doesn’t open, the tags are text rather than buttons, and the host is :state(readonly).
show(), hide() and toggle() open and close the listbox from code, as open does. showPicker() opens it too, but like a native input’s, it only works from a user gesture, such as a click, and throws while it’s disabled or read-only.
Long lists
For thousands of Options, set virtual, as on Listbox. Only the Options in or near view are laid out, filtering and the arrow keys still reach every one, and the listbox scrolls to the selected Option as it opens. Give ::part(listbox) a maximum block size so it scrolls.
<style>
slab-combobox::part(listbox) {
max-block-size: 20rem;
}
</style>
<slab-combobox label="City" virtual>
<slab-option>Aachen</slab-option>
<slab-option>Aalborg</slab-option>
<!-- And thousands more -->
</slab-combobox>
Keyboard
| Key | What it does |
|---|---|
| Up, Down | Opens the listbox and moves the active Option, stopping at each end and skipping disabled ones. |
| Alt+Down | Opens the listbox without moving. |
| Alt+Up | Closes the listbox. |
| Enter | Selects the active Option and closes the listbox. |
| Escape | Closes the listbox, and a second Escape clears the input. |
| Home, End | Move the caret, as in any input. |
With multiple, Enter toggles the active Option and leaves the listbox open, and a second Escape clears only what’s typed. These are added:
| Key | What it does |
|---|---|
| Backspace | In an empty input, removes the last tag. |
| Left | At the start of the input, moves to the last tag. |
| Left, Right | On a tag, moves to the previous or next one. Right from the last goes back to the input. |
| Backspace, Delete, Enter, Space | On a tag, removes it and moves to the one that takes its place, or the input when there’s none. |
| Escape | On a tag, goes back to the input. |
Behavior
A text input that filters a list of Options as it's typed into, with no visual styles. It's the APG's editable combobox with list autocomplete.
Not <input list>. A <datalist> holds only text, can't be styled, and is drawn differently by every browser, down to whether it filters by prefix or by substring. So this is a real <input role="combobox"> with a <div role="listbox"> of slotted Options in a popover beside it.
The listbox is its own rather than a nested Listbox. A Listbox has a label, a Tab stop and a form value of its own, all of which a Combobox would have to switch off. What it shares with Listbox is Option, OptionsController, and the way the active Option is pointed at rather than focused: focus stays in the input, and the input's aria-activedescendant is set as an element, since an IDREF can't reach the slotted Options. Read or set it with activeOption.
Typing filters the Options by filter, a case-insensitive substring of each Option's text unless it's replaced, and opens the listbox. An Option that doesn't match is hidden, so it's out of the accessibility tree and skipped by the arrow keys. With none left, the listbox closes and the host matches :state(empty), for a "no results" message of your own. Screenreaders are told how many Options are left once typing pauses, from resultsLabel.
ArrowDown and ArrowUp open the listbox and move the active Option, stopping at each end and skipping disabled Options. Alt with ArrowDown opens it without moving, and Alt with ArrowUp closes it. Enter and a click select the active Option and close the listbox. Escape closes it, and a second Escape clears the input. Home, End and the other caret keys stay the input's. A click or Tab elsewhere closes it, since either takes focus from the input.
value is the selected Option's value, not what's in the input, which shows that Option's text. Unless allow-custom is set, what's typed has to name an Option: when focus leaves, text that matches one's (ignoring case) selects it, an empty input clears the selection, and anything else goes back to the selected Option's text. With allow-custom, text that matches no Option is the value as typed. Either way, value is what's submitted, and "input" and "change" are dispatched together when it changes, as on a <select>, rather than on every keystroke.
With multiple, choosing an Option toggles it and leaves the listbox open, and what's typed is cleared rather than replaced by the Option's text. Each selected value is shown before the input as a tag, a <button> that removes it. Backspace in an empty input removes the last, and Left at the start of the input moves focus to the tags, where Left and Right move between them and Backspace, Delete, Enter and Space remove one. In a right-to-left page, Left and Right swap. They aren't Tab stops, so Tab still leaves the Combobox in one press. values lists the selected values in the order they were chosen, and each is submitted as its own entry, as a <select multiple> submits them. Text that names an Option adds it, and with allow-custom so does text that names none.
readonly shows the value without letting the user change it: the input can't be typed in, the listbox doesn't open, and the tags are text rather than buttons. It's still focused, read and submitted, where disabled leaves it out of the form, and never invalid.
Style it through its parts and through :state(disabled), :state(empty), :state(error), :state(open), :state(readonly) and :state(required), and each Option through :state(active), :state(disabled) and :state(selected). The tags are ::part(tag), in ::part(tags).
API
<slab-combobox>
| Name | Type | Default | Description |
|---|---|---|---|
label
Required
|
string |
Names it. It's the accessible name, and the visible label where there is one. | |
allow-custom
|
boolean |
false |
Lets the value be text that matches no Option. |
disabled
|
boolean |
false |
Disables it, as disabled does a native control: the user can't focus or use it, and a form control's value isn't submitted. |
hide-label
|
boolean |
false |
Hides the label visually and leaves it as the accessible name, for a design that shows the label some other way. |
multiple
|
boolean |
false |
Lets more than one Option be selected, each shown as a tag that removes it. |
name
|
string |
'' |
The name its value is submitted under, as a native control's name. |
open
|
boolean |
false |
Whether it's open. Set it to open or close it. |
placeholder
|
string |
Shown while it's empty, as a native input's placeholder. It's a hint, not a label. |
|
readonly
|
boolean |
false |
Shows the value without letting the user change it. The listbox doesn't open and the tags can't be removed. It's still focusable and submitted, and never invalid, as a native read-only input isn't. |
placement
|
'bottom' | 'top' |
'bottom' |
The side of the input the listbox opens on, when there's room. It flips when there isn't. |
required
|
boolean |
false |
Makes it invalid while it has no value, as required does a native control. |
virtual
|
boolean |
false |
Lays out only the Options in or near view, for a Combobox with thousands. Give ::part(listbox) a maximum block size so it scrolls. Options are taken to be the same height as each other. |
value
|
string |
'' |
The selected Option's value, or the typed text when allow-custom is set and it matches no Option. The first of values when multiple is set. Setting it selects the Option with that value, and only that one. Like a native input, the attribute is the default value and the property is the current one. |
custom-validity
|
string |
Makes it invalid with this message, as setCustomValidity() does, and shows the message at once rather than once validity is reported, for an error the page already knows about, such as one from a server. Removing it, or setting it to an empty string, makes it valid again, unless something else makes it invalid. |
| Name | Type | Description |
|---|---|---|
filter
|
(option: Option, query: string) => boolean |
Whether an Option matches what's been typed. A case-insensitive substring of its text by default. |
removeLabel
|
(text: string) => string |
Names each tag's button, which shows only the selected Option's text, from that text. "Remove" and the text in English when unset. |
removedLabel
|
(text: string) => string |
What screenreaders are told when a tag is removed, from its text. The text and "removed" in English when unset. |
resultsLabel
|
(count: number) => string |
What screenreaders are told once typing pauses, from how many Options are left. "No results", "1 result" and so on in English when unset. |
values
|
string[] |
Every selected value, in the order they were chosen. Only the first when multiple isn't set. Setting it selects the Options with those values, and only those. |
defaultValue
|
string |
The value it selects when none of its Options has selected, and goes back to when its form resets. It's the value attribute, so setting it sets the attribute, and value with it. |
activeOption
|
Option | null |
The Option the user is on, which Enter selects. It's pointed at rather than focused, so focus stays in the input. |
form
Read-only
|
HTMLFormElement | null |
The form it belongs to, or null. |
labels
Read-only
|
NodeList |
The <label> elements associated with it, as a native control's labels: each <label for> that names its id, and a <label> around it. |
options
Read-only
|
Option[] |
Its Options, in order. |
selectedOption
Read-only
|
Option | null |
The first selected Option, or null. |
selectedOptions
Read-only
|
Option[] |
The Options of values, in the same order. Values that name no Option are left out. |
validationMessage
Read-only
|
string |
What's wrong, as the validity message says it: the message given to setCustomValidity() or setValidity(), or else the browser's own. Empty while it's valid. |
validity
Read-only
|
ValidityState |
Its ValidityState, as a native control's. |
willValidate
Read-only
|
boolean |
Whether its validity is checked when its form submits. It isn't while it's disabled or read-only. |
| Signature | Description |
|---|---|
checkValidity(): boolean
|
Whether its value is valid. Dispatches "invalid" when it isn't, as a native control's does. |
focus(options?: FocusOptions): void
|
Focuses it, or the part of it that takes focus. |
hide(): void
|
Closes the listbox. |
reportValidity(): boolean
|
Whether its value is valid. When it isn't, dispatches "invalid" and shows the validity message, as a native control's does. |
resetValidityFeedback(): void
|
Clears the validity feedback without changing validity. |
setCustomValidity(message: string): void
|
Makes it invalid with a message of your own, or valid again with an empty one, as a native control's does. |
setValidity(flags?: ValidityStateFlags, message?: string): void
|
Sets its validity and message, as ElementInternals.setValidity() does, for checks of your own beyond setCustomValidity(). |
show(): void
|
Opens the listbox, unless there's nothing in it to choose: while it's disabled, or when no Option matches what's typed. |
showPicker(): void
|
Opens the listbox, as show() does. As a native input's, it throws without a user gesture, or while it's disabled or read-only. |
toggle(force?: boolean): boolean
|
Opens it when it's closed, and closes it when it's open, as a native popover's togglePopover() does. true only opens it and false only closes it. Returns whether it's open. |
| Name | Type | Description |
|---|---|---|
toggle
|
ToggleEvent |
When it opens or closes, as a ToggleEvent with oldState and newState that doesn't bubble, as a popover's does. |
input
|
Event |
As the user changes its value, as a native control's does. Setting it from code doesn't dispatch it. |
change
|
Event |
When the user changes its value, as a native control's does. Setting it from code doesn't dispatch it. |
invalid
|
Event |
When a check finds its value invalid, as a native control's does. Cancel it to leave the validity message unshown, after a blur, a submit or reportValidity(), and focus where it is. |
beforetoggle
|
ToggleEvent |
Before it opens or closes, as a ToggleEvent that doesn't bubble. Cancel it while it's opening to keep it closed. |
| Name | Type | Description |
|---|---|---|
(default)
|
Option | OptionGroup |
|
description
|
Element | string |
Text that describes it, such as a hint or what the validity message means. It's its accessible description. |
validity-message
|
Element | string |
Shown in place of the validity message's text while it's invalid and the message shows, for wording of your own, a translation, or a link. It's part of its accessible description, and validationMessage stays the browser's or setCustomValidity()'s. |
| Name | Description |
|---|---|
description
|
Text about the Combobox, and its validity message when it has one |
input
|
The input |
label
|
The label |
listbox
|
The Options, in a popover beside the input |
tag
|
A selected value's button, which removes it |
tags
|
The tags |
validity-message
|
The validity message, which says why the value is invalid |
| Name | Description |
|---|---|
:state(disabled)
|
While it's disabled. |
:state(empty)
|
While no option matches what the user typed, for a "no results" message of your own. |
:state(error)
|
While it's invalid and its validity message shows, which is once its validity is reported, as when its form is submitted. |
:state(open)
|
While it's open. |
:state(readonly)
|
While it's read-only. |
:state(required)
|
While it's required, for styles such as an asterisk. |
Copy and own it
<slab-styled-combobox> isn't in the package. It's an example —
copy it into your project and change whatever you want. Keyboard,
focus, ARIA, forms, and events all come from the headless element,
and the styles only reach in through ::part() and
:state(), same as yours would.
The same styles, written from outside the element, so
there's nothing to subclass. The CSS styles every
<slab-combobox> on the page. Import
tokens.css, the colors and fonts every styled
example shares, once, wherever your global styles go.
Each component registers its headless element and imports its CSS. Use it like the element: its props are the element's attributes and properties.
Combobox.jsx
import 'slab-elements/combobox.js';
import './combobox.css';
export function Combobox(props) {
return <slab-combobox {...props} />;
}
combobox.css
slab-combobox {
color: var(--ink);
display: grid;
font-family: var(--font-body);
}
slab-combobox::part(label) {
font-family: var(--font-display);
font-size: 1.0625rem;
font-weight: 600;
margin-block-end: 0.375rem;
}
slab-combobox:state(required)::part(label)::after {
color: var(--ember-deep);
content: ' *' / '';
}
slab-combobox::part(input),
slab-combobox::part(textarea) {
background-color: var(--paper);
block-size: 3rem;
border: var(--border);
border-radius: 0;
box-sizing: border-box;
color: inherit;
font: inherit;
/* A fixed height, shared with Select, so fields line up in a row. */
padding: 0 0.75rem;
transition:
background-color 100ms,
border-color 100ms,
box-shadow 100ms,
translate 100ms;
}
slab-combobox::part(input)::placeholder,
slab-combobox::part(textarea)::placeholder {
color: var(--ash);
}
/*
The outline is transparent rather than gone, so it still shows in forced
colors, where box shadows don't.
*/
slab-combobox::part(input):focus-visible,
slab-combobox::part(textarea):focus-visible {
box-shadow: 4px 4px 0 var(--ember);
outline: 2px solid transparent;
translate: -2px -2px;
}
slab-combobox::part(input):disabled,
slab-combobox::part(textarea):disabled {
background-color: var(--chalk);
border-style: dashed;
color: var(--ash);
cursor: not-allowed;
}
slab-combobox::part(textarea) {
block-size: auto;
min-block-size: 7rem;
padding: 0.625rem 0.75rem;
resize: vertical;
}
slab-combobox:state(readonly)::part(input),
slab-combobox:state(readonly)::part(textarea) {
background-color: var(--chalk);
}
slab-combobox:state(error)::part(input),
slab-combobox:state(error)::part(textarea) {
border-color: var(--ember-deep);
}
/*
Spaced by what's in it rather than by a gap, so a description with
nothing in it takes no room, and a control beside the field lines up
with its bottom edge.
*/
slab-combobox::part(description) {
color: var(--ash);
display: grid;
font-size: 0.875rem;
}
slab-combobox > [slot='description'] {
margin-block-start: 0.375rem;
}
slab-combobox::part(validity-message) {
color: var(--ember-deep);
font-weight: 600;
margin-block-start: 0.375rem;
}
slab-combobox::part(validity-message)::before {
content: '■ ' / '';
}
@media (prefers-reduced-motion: reduce) {
slab-combobox::part(input),
slab-combobox::part(textarea) {
transition: none;
}
}
slab-combobox::part(listbox) {
animation: slab-combobox-drop 150ms ease-out;
background-color: var(--paper);
border: var(--border);
box-shadow: var(--shadow);
box-sizing: border-box;
color: var(--ink);
margin-block: 0.5rem;
max-block-size: 18rem;
min-inline-size: anchor-size(inline);
overflow-y: auto;
padding: 0.25rem 0;
}
/*
With "multiple", the tags sit in a row between the label and the input,
rather than inside it, so the input keeps Text Field's fixed height.
*/
slab-combobox::part(tags) {
column-gap: 0.375rem;
display: flex;
flex-wrap: wrap;
}
slab-combobox::part(tag) {
align-items: center;
background-color: var(--paper);
border: var(--border);
border-radius: 0;
color: var(--ink);
cursor: pointer;
display: inline-flex;
font: inherit;
font-size: 0.875rem;
font-weight: 600;
gap: 0.5rem;
/* Below each tag rather than below the row, so no tags take no room. */
margin-block-end: 0.375rem;
padding: 0.125rem 0.5rem;
transition:
background-color 100ms,
color 100ms;
}
/* The cross: what a click does. */
slab-combobox::part(tag)::after {
content: '×' / '';
font-size: 1.125rem;
line-height: 1;
}
slab-combobox::part(tag):hover {
background-color: var(--chalk);
}
slab-combobox::part(tag):focus-visible {
background-color: var(--ember-deep);
color: var(--paper);
outline: 2px solid transparent;
}
slab-combobox::part(tag):disabled {
background-color: var(--chalk);
border-style: dashed;
color: var(--ash);
cursor: not-allowed;
}
@keyframes slab-combobox-drop {
from {
opacity: 0;
translate: 0 -0.375rem;
}
}
@media (prefers-reduced-motion: reduce) {
slab-combobox::part(listbox) {
animation: none;
}
slab-combobox::part(tag) {
transition: none;
}
}
tokens.css
:root {
/* Secondary text. 6.8:1 and 6.9:1 on paper. */
--ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
--border: 2px solid var(--ink);
/* Behind disabled and read-only controls, and hovered rows. */
--chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));
/*
The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
enough for borders, fills and large text, but not always for small text,
which takes "--ember-deep".
*/
--ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));
/*
Orange for small text on paper, and for paper text on it. 5.7:1 and
7.4:1.
*/
--ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
--font-body: var(
--slab-styled-font-body,
'IBM Plex Sans',
system-ui,
sans-serif
);
--font-display: var(
--slab-styled-font-display,
'Zilla Slab',
rockwell,
'Roboto Slab',
serif
);
--font-mono: var(
--slab-styled-font-mono,
'IBM Plex Mono',
ui-monospace,
monospace
);
--ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
--paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));
/* The hard, offset shadow a raised surface casts. */
--shadow: 4px 4px 0 var(--ink);
}
/*
Forced colors, such as Windows' contrast themes, replace every color that
isn't a system color, so ember fills and paper marks all become the same
background, and a checked Checkbox looks like an unchecked one. The palette
becomes the user's system colors instead, which are kept. Ember is the
highlight, the color of what's selected, and ember-deep, being for text and
for paper text on it, is the text color.
*/
@media (forced-colors: active) {
:host {
--ash: GrayText;
--chalk: Canvas;
--ember: Highlight;
--ember-deep: CanvasText;
--ink: CanvasText;
--paper: Canvas;
}
}
Under the hood, it's just the headless element, subclassed,
with styles set. That's it. To use it, copy
these files, swap the tag in @customElement()
for one of your own, and import it.
tokens.styles.ts holds the colors and fonts
every styled example shares, so you only need it once.
combobox.ts
import { customElement } from 'lit/decorators.js';
import Combobox from 'slab-elements/combobox.js';
import textInput from './text-input.styles.js';
import styles from './combobox.styles.js';
import tokens from './tokens.styles.js';
declare global {
interface HTMLElementTagNameMap {
'slab-styled-combobox': StyledCombobox;
}
}
/**
* Combobox, styled: Text Field's input, with its Options in a panel that
* casts a hard shadow, as Select's do.
*/
@customElement('slab-styled-combobox')
export default class StyledCombobox extends Combobox {
static override styles = [tokens, textInput, styles];
}
text-input.styles.ts
import { css } from 'lit';
/*
The look shared by everything typed into: Text Field, Password Field,
Search Field, Textarea, Number, Date Field, Time Field, Combobox and Tags
Input, whose fields are "::part(input)", or "::part(textarea)" for Textarea.
File Drop starts from it too, for its label and description.
*/
export default css`
:host {
color: var(--ink);
display: grid;
font-family: var(--font-body);
}
[part~='label'] {
font-family: var(--font-display);
font-size: 1.0625rem;
font-weight: 600;
margin-block-end: 0.375rem;
}
:host(:state(required)) [part~='label']::after {
color: var(--ember-deep);
content: ' *' / '';
}
[part~='input'],
[part~='textarea'] {
background-color: var(--paper);
block-size: 3rem;
border: var(--border);
border-radius: 0;
box-sizing: border-box;
color: inherit;
font: inherit;
/* A fixed height, shared with Select, so fields line up in a row. */
padding: 0 0.75rem;
transition:
background-color 100ms,
border-color 100ms,
box-shadow 100ms,
translate 100ms;
&::placeholder {
color: var(--ash);
}
/*
The outline is transparent rather than gone, so it still shows in forced
colors, where box shadows don't.
*/
&:focus-visible {
box-shadow: 4px 4px 0 var(--ember);
outline: 2px solid transparent;
translate: -2px -2px;
}
&:disabled {
background-color: var(--chalk);
border-style: dashed;
color: var(--ash);
cursor: not-allowed;
}
}
[part~='textarea'] {
block-size: auto;
min-block-size: 7rem;
padding: 0.625rem 0.75rem;
resize: vertical;
}
:host(:state(readonly)) [part~='input'],
:host(:state(readonly)) [part~='textarea'] {
background-color: var(--chalk);
}
:host(:state(error)) [part~='input'],
:host(:state(error)) [part~='textarea'] {
border-color: var(--ember-deep);
}
/*
Spaced by what's in it rather than by a gap, so a description with
nothing in it takes no room, and a control beside the field lines up
with its bottom edge.
*/
[part~='description'] {
color: var(--ash);
display: grid;
font-size: 0.875rem;
}
::slotted([slot='description']) {
margin-block-start: 0.375rem;
}
[part~='validity-message'] {
color: var(--ember-deep);
font-weight: 600;
margin-block-start: 0.375rem;
&::before {
content: '■ ' / '';
}
}
@media (prefers-reduced-motion: reduce) {
[part~='input'],
[part~='textarea'] {
transition: none;
}
}
`;
combobox.styles.ts
import { css } from 'lit';
/*
Text Field's input, with the listbox in a panel beside it like Select's,
and the tags of "multiple" as bordered chips above it.
The listbox is a popover, so a closed one isn't displayed, and its entrance
runs each time it opens.
*/
export default css`
[part~='listbox'] {
animation: drop 150ms ease-out;
background-color: var(--paper);
border: var(--border);
box-shadow: var(--shadow);
box-sizing: border-box;
color: var(--ink);
margin-block: 0.5rem;
max-block-size: 18rem;
min-inline-size: anchor-size(inline);
overflow-y: auto;
padding: 0.25rem 0;
}
/*
With "multiple", the tags sit in a row between the label and the input,
rather than inside it, so the input keeps Text Field's fixed height.
*/
[part~='tags'] {
column-gap: 0.375rem;
display: flex;
flex-wrap: wrap;
}
[part~='tag'] {
align-items: center;
background-color: var(--paper);
border: var(--border);
border-radius: 0;
color: var(--ink);
cursor: pointer;
display: inline-flex;
font: inherit;
font-size: 0.875rem;
font-weight: 600;
gap: 0.5rem;
/* Below each tag rather than below the row, so no tags take no room. */
margin-block-end: 0.375rem;
padding: 0.125rem 0.5rem;
transition:
background-color 100ms,
color 100ms;
/* The cross: what a click does. */
&::after {
content: '×' / '';
font-size: 1.125rem;
line-height: 1;
}
&:hover {
background-color: var(--chalk);
}
&:focus-visible {
background-color: var(--ember-deep);
color: var(--paper);
outline: 2px solid transparent;
}
&:disabled {
background-color: var(--chalk);
border-style: dashed;
color: var(--ash);
cursor: not-allowed;
}
}
@keyframes drop {
from {
opacity: 0;
translate: 0 -0.375rem;
}
}
@media (prefers-reduced-motion: reduce) {
[part~='listbox'] {
animation: none;
}
[part~='tag'] {
transition: none;
}
}
`;
tokens.styles.ts
import { css } from 'lit';
/*
The styled components' palette and type, taken from the logo: ink for the
courses, ember for the base, paper behind them.
Each is a short alias for a "--slab-styled-*" property, with the default as
its fallback. Retheming is "--slab-styled-ember" and the rest on ":root",
which every shadow root inherits. Were the defaults declared under those
names here instead, each host's own declaration would shadow the page's.
Each default is "light-dark()", so the components follow the page's
"color-scheme": "dark" for dark, "light" for light, and "light dark" to
follow the operating system. Ink and paper trade places in the dark, so
ink is always the text and paper always what's behind it. Contrast is given
as light, then dark.
*/
export default css`
:host {
/* Secondary text. 6.8:1 and 6.9:1 on paper. */
--ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
--border: 2px solid var(--ink);
/* Behind disabled and read-only controls, and hovered rows. */
--chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));
/*
The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
enough for borders, fills and large text, but not always for small text,
which takes "--ember-deep".
*/
--ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));
/*
Orange for small text on paper, and for paper text on it. 5.7:1 and
7.4:1.
*/
--ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
--font-body: var(
--slab-styled-font-body,
'IBM Plex Sans',
system-ui,
sans-serif
);
--font-display: var(
--slab-styled-font-display,
'Zilla Slab',
rockwell,
'Roboto Slab',
serif
);
--font-mono: var(
--slab-styled-font-mono,
'IBM Plex Mono',
ui-monospace,
monospace
);
--ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
--paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));
/* The hard, offset shadow a raised surface casts. */
--shadow: 4px 4px 0 var(--ink);
}
/*
Forced colors, such as Windows' contrast themes, replace every color that
isn't a system color, so ember fills and paper marks all become the same
background, and a checked Checkbox looks like an unchecked one. The palette
becomes the user's system colors instead, which are kept. Ember is the
highlight, the color of what's selected, and ember-deep, being for text and
for paper text on it, is the text color.
*/
@media (forced-colors: active) {
:host {
--ash: GrayText;
--chalk: Canvas;
--ember: Highlight;
--ember-deep: CanvasText;
--ink: CanvasText;
--paper: Canvas;
}
}
`;
The same styles, written from outside the element, so
there's nothing to subclass. The CSS styles every
<slab-combobox> on the page. Import
tokens.css, the colors and fonts every styled
example shares, once, wherever your global styles go.
Each component registers its headless element and imports its CSS. Use it like the element: its props are the element's attributes and properties.
Combobox.vue
<script setup>
import 'slab-elements/combobox.js';
import './combobox.css';
</script>
<template>
<slab-combobox><slot /></slab-combobox>
</template>
combobox.css
slab-combobox {
color: var(--ink);
display: grid;
font-family: var(--font-body);
}
slab-combobox::part(label) {
font-family: var(--font-display);
font-size: 1.0625rem;
font-weight: 600;
margin-block-end: 0.375rem;
}
slab-combobox:state(required)::part(label)::after {
color: var(--ember-deep);
content: ' *' / '';
}
slab-combobox::part(input),
slab-combobox::part(textarea) {
background-color: var(--paper);
block-size: 3rem;
border: var(--border);
border-radius: 0;
box-sizing: border-box;
color: inherit;
font: inherit;
/* A fixed height, shared with Select, so fields line up in a row. */
padding: 0 0.75rem;
transition:
background-color 100ms,
border-color 100ms,
box-shadow 100ms,
translate 100ms;
}
slab-combobox::part(input)::placeholder,
slab-combobox::part(textarea)::placeholder {
color: var(--ash);
}
/*
The outline is transparent rather than gone, so it still shows in forced
colors, where box shadows don't.
*/
slab-combobox::part(input):focus-visible,
slab-combobox::part(textarea):focus-visible {
box-shadow: 4px 4px 0 var(--ember);
outline: 2px solid transparent;
translate: -2px -2px;
}
slab-combobox::part(input):disabled,
slab-combobox::part(textarea):disabled {
background-color: var(--chalk);
border-style: dashed;
color: var(--ash);
cursor: not-allowed;
}
slab-combobox::part(textarea) {
block-size: auto;
min-block-size: 7rem;
padding: 0.625rem 0.75rem;
resize: vertical;
}
slab-combobox:state(readonly)::part(input),
slab-combobox:state(readonly)::part(textarea) {
background-color: var(--chalk);
}
slab-combobox:state(error)::part(input),
slab-combobox:state(error)::part(textarea) {
border-color: var(--ember-deep);
}
/*
Spaced by what's in it rather than by a gap, so a description with
nothing in it takes no room, and a control beside the field lines up
with its bottom edge.
*/
slab-combobox::part(description) {
color: var(--ash);
display: grid;
font-size: 0.875rem;
}
slab-combobox > [slot='description'] {
margin-block-start: 0.375rem;
}
slab-combobox::part(validity-message) {
color: var(--ember-deep);
font-weight: 600;
margin-block-start: 0.375rem;
}
slab-combobox::part(validity-message)::before {
content: '■ ' / '';
}
@media (prefers-reduced-motion: reduce) {
slab-combobox::part(input),
slab-combobox::part(textarea) {
transition: none;
}
}
slab-combobox::part(listbox) {
animation: slab-combobox-drop 150ms ease-out;
background-color: var(--paper);
border: var(--border);
box-shadow: var(--shadow);
box-sizing: border-box;
color: var(--ink);
margin-block: 0.5rem;
max-block-size: 18rem;
min-inline-size: anchor-size(inline);
overflow-y: auto;
padding: 0.25rem 0;
}
/*
With "multiple", the tags sit in a row between the label and the input,
rather than inside it, so the input keeps Text Field's fixed height.
*/
slab-combobox::part(tags) {
column-gap: 0.375rem;
display: flex;
flex-wrap: wrap;
}
slab-combobox::part(tag) {
align-items: center;
background-color: var(--paper);
border: var(--border);
border-radius: 0;
color: var(--ink);
cursor: pointer;
display: inline-flex;
font: inherit;
font-size: 0.875rem;
font-weight: 600;
gap: 0.5rem;
/* Below each tag rather than below the row, so no tags take no room. */
margin-block-end: 0.375rem;
padding: 0.125rem 0.5rem;
transition:
background-color 100ms,
color 100ms;
}
/* The cross: what a click does. */
slab-combobox::part(tag)::after {
content: '×' / '';
font-size: 1.125rem;
line-height: 1;
}
slab-combobox::part(tag):hover {
background-color: var(--chalk);
}
slab-combobox::part(tag):focus-visible {
background-color: var(--ember-deep);
color: var(--paper);
outline: 2px solid transparent;
}
slab-combobox::part(tag):disabled {
background-color: var(--chalk);
border-style: dashed;
color: var(--ash);
cursor: not-allowed;
}
@keyframes slab-combobox-drop {
from {
opacity: 0;
translate: 0 -0.375rem;
}
}
@media (prefers-reduced-motion: reduce) {
slab-combobox::part(listbox) {
animation: none;
}
slab-combobox::part(tag) {
transition: none;
}
}
tokens.css
:root {
/* Secondary text. 6.8:1 and 6.9:1 on paper. */
--ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
--border: 2px solid var(--ink);
/* Behind disabled and read-only controls, and hovered rows. */
--chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));
/*
The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
enough for borders, fills and large text, but not always for small text,
which takes "--ember-deep".
*/
--ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));
/*
Orange for small text on paper, and for paper text on it. 5.7:1 and
7.4:1.
*/
--ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
--font-body: var(
--slab-styled-font-body,
'IBM Plex Sans',
system-ui,
sans-serif
);
--font-display: var(
--slab-styled-font-display,
'Zilla Slab',
rockwell,
'Roboto Slab',
serif
);
--font-mono: var(
--slab-styled-font-mono,
'IBM Plex Mono',
ui-monospace,
monospace
);
--ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
--paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));
/* The hard, offset shadow a raised surface casts. */
--shadow: 4px 4px 0 var(--ink);
}
/*
Forced colors, such as Windows' contrast themes, replace every color that
isn't a system color, so ember fills and paper marks all become the same
background, and a checked Checkbox looks like an unchecked one. The palette
becomes the user's system colors instead, which are kept. Ember is the
highlight, the color of what's selected, and ember-deep, being for text and
for paper text on it, is the text color.
*/
@media (forced-colors: active) {
:host {
--ash: GrayText;
--chalk: Canvas;
--ember: Highlight;
--ember-deep: CanvasText;
--ink: CanvasText;
--paper: Canvas;
}
}
The same styles, written from outside the element, so
there's nothing to subclass. The CSS styles every
<slab-combobox> on the page. Import
tokens.css, the colors and fonts every styled
example shares, once, wherever your global styles go.
Import combobox.js once, such
as in your root layout, and use
<slab-combobox> as is. A Svelte component
around it would take slot="…" content as its
own slot and drop it.
combobox.js
import 'slab-elements/combobox.js';
import './combobox.css';
combobox.css
slab-combobox {
color: var(--ink);
display: grid;
font-family: var(--font-body);
}
slab-combobox::part(label) {
font-family: var(--font-display);
font-size: 1.0625rem;
font-weight: 600;
margin-block-end: 0.375rem;
}
slab-combobox:state(required)::part(label)::after {
color: var(--ember-deep);
content: ' *' / '';
}
slab-combobox::part(input),
slab-combobox::part(textarea) {
background-color: var(--paper);
block-size: 3rem;
border: var(--border);
border-radius: 0;
box-sizing: border-box;
color: inherit;
font: inherit;
/* A fixed height, shared with Select, so fields line up in a row. */
padding: 0 0.75rem;
transition:
background-color 100ms,
border-color 100ms,
box-shadow 100ms,
translate 100ms;
}
slab-combobox::part(input)::placeholder,
slab-combobox::part(textarea)::placeholder {
color: var(--ash);
}
/*
The outline is transparent rather than gone, so it still shows in forced
colors, where box shadows don't.
*/
slab-combobox::part(input):focus-visible,
slab-combobox::part(textarea):focus-visible {
box-shadow: 4px 4px 0 var(--ember);
outline: 2px solid transparent;
translate: -2px -2px;
}
slab-combobox::part(input):disabled,
slab-combobox::part(textarea):disabled {
background-color: var(--chalk);
border-style: dashed;
color: var(--ash);
cursor: not-allowed;
}
slab-combobox::part(textarea) {
block-size: auto;
min-block-size: 7rem;
padding: 0.625rem 0.75rem;
resize: vertical;
}
slab-combobox:state(readonly)::part(input),
slab-combobox:state(readonly)::part(textarea) {
background-color: var(--chalk);
}
slab-combobox:state(error)::part(input),
slab-combobox:state(error)::part(textarea) {
border-color: var(--ember-deep);
}
/*
Spaced by what's in it rather than by a gap, so a description with
nothing in it takes no room, and a control beside the field lines up
with its bottom edge.
*/
slab-combobox::part(description) {
color: var(--ash);
display: grid;
font-size: 0.875rem;
}
slab-combobox > [slot='description'] {
margin-block-start: 0.375rem;
}
slab-combobox::part(validity-message) {
color: var(--ember-deep);
font-weight: 600;
margin-block-start: 0.375rem;
}
slab-combobox::part(validity-message)::before {
content: '■ ' / '';
}
@media (prefers-reduced-motion: reduce) {
slab-combobox::part(input),
slab-combobox::part(textarea) {
transition: none;
}
}
slab-combobox::part(listbox) {
animation: slab-combobox-drop 150ms ease-out;
background-color: var(--paper);
border: var(--border);
box-shadow: var(--shadow);
box-sizing: border-box;
color: var(--ink);
margin-block: 0.5rem;
max-block-size: 18rem;
min-inline-size: anchor-size(inline);
overflow-y: auto;
padding: 0.25rem 0;
}
/*
With "multiple", the tags sit in a row between the label and the input,
rather than inside it, so the input keeps Text Field's fixed height.
*/
slab-combobox::part(tags) {
column-gap: 0.375rem;
display: flex;
flex-wrap: wrap;
}
slab-combobox::part(tag) {
align-items: center;
background-color: var(--paper);
border: var(--border);
border-radius: 0;
color: var(--ink);
cursor: pointer;
display: inline-flex;
font: inherit;
font-size: 0.875rem;
font-weight: 600;
gap: 0.5rem;
/* Below each tag rather than below the row, so no tags take no room. */
margin-block-end: 0.375rem;
padding: 0.125rem 0.5rem;
transition:
background-color 100ms,
color 100ms;
}
/* The cross: what a click does. */
slab-combobox::part(tag)::after {
content: '×' / '';
font-size: 1.125rem;
line-height: 1;
}
slab-combobox::part(tag):hover {
background-color: var(--chalk);
}
slab-combobox::part(tag):focus-visible {
background-color: var(--ember-deep);
color: var(--paper);
outline: 2px solid transparent;
}
slab-combobox::part(tag):disabled {
background-color: var(--chalk);
border-style: dashed;
color: var(--ash);
cursor: not-allowed;
}
@keyframes slab-combobox-drop {
from {
opacity: 0;
translate: 0 -0.375rem;
}
}
@media (prefers-reduced-motion: reduce) {
slab-combobox::part(listbox) {
animation: none;
}
slab-combobox::part(tag) {
transition: none;
}
}
tokens.css
:root {
/* Secondary text. 6.8:1 and 6.9:1 on paper. */
--ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
--border: 2px solid var(--ink);
/* Behind disabled and read-only controls, and hovered rows. */
--chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));
/*
The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
enough for borders, fills and large text, but not always for small text,
which takes "--ember-deep".
*/
--ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));
/*
Orange for small text on paper, and for paper text on it. 5.7:1 and
7.4:1.
*/
--ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
--font-body: var(
--slab-styled-font-body,
'IBM Plex Sans',
system-ui,
sans-serif
);
--font-display: var(
--slab-styled-font-display,
'Zilla Slab',
rockwell,
'Roboto Slab',
serif
);
--font-mono: var(
--slab-styled-font-mono,
'IBM Plex Mono',
ui-monospace,
monospace
);
--ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
--paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));
/* The hard, offset shadow a raised surface casts. */
--shadow: 4px 4px 0 var(--ink);
}
/*
Forced colors, such as Windows' contrast themes, replace every color that
isn't a system color, so ember fills and paper marks all become the same
background, and a checked Checkbox looks like an unchecked one. The palette
becomes the user's system colors instead, which are kept. Ember is the
highlight, the color of what's selected, and ember-deep, being for text and
for paper text on it, is the text color.
*/
@media (forced-colors: active) {
:host {
--ash: GrayText;
--chalk: Canvas;
--ember: Highlight;
--ember-deep: CanvasText;
--ink: CanvasText;
--paper: Canvas;
}
}
The same styles, written from outside the element, so
there's nothing to subclass. The CSS styles every
<slab-combobox> on the page. Import
tokens.css, the colors and fonts every styled
example shares, once, wherever your global styles go.
Each component registers its headless element and imports its CSS. Use it like the element: its attributes and its content go to the element.
Combobox.gjs
import 'slab-elements/combobox.js';
import './combobox.css';
export const Combobox = <template>
<slab-combobox ...attributes>{{yield}}</slab-combobox>
</template>;
combobox.css
slab-combobox {
color: var(--ink);
display: grid;
font-family: var(--font-body);
}
slab-combobox::part(label) {
font-family: var(--font-display);
font-size: 1.0625rem;
font-weight: 600;
margin-block-end: 0.375rem;
}
slab-combobox:state(required)::part(label)::after {
color: var(--ember-deep);
content: ' *' / '';
}
slab-combobox::part(input),
slab-combobox::part(textarea) {
background-color: var(--paper);
block-size: 3rem;
border: var(--border);
border-radius: 0;
box-sizing: border-box;
color: inherit;
font: inherit;
/* A fixed height, shared with Select, so fields line up in a row. */
padding: 0 0.75rem;
transition:
background-color 100ms,
border-color 100ms,
box-shadow 100ms,
translate 100ms;
}
slab-combobox::part(input)::placeholder,
slab-combobox::part(textarea)::placeholder {
color: var(--ash);
}
/*
The outline is transparent rather than gone, so it still shows in forced
colors, where box shadows don't.
*/
slab-combobox::part(input):focus-visible,
slab-combobox::part(textarea):focus-visible {
box-shadow: 4px 4px 0 var(--ember);
outline: 2px solid transparent;
translate: -2px -2px;
}
slab-combobox::part(input):disabled,
slab-combobox::part(textarea):disabled {
background-color: var(--chalk);
border-style: dashed;
color: var(--ash);
cursor: not-allowed;
}
slab-combobox::part(textarea) {
block-size: auto;
min-block-size: 7rem;
padding: 0.625rem 0.75rem;
resize: vertical;
}
slab-combobox:state(readonly)::part(input),
slab-combobox:state(readonly)::part(textarea) {
background-color: var(--chalk);
}
slab-combobox:state(error)::part(input),
slab-combobox:state(error)::part(textarea) {
border-color: var(--ember-deep);
}
/*
Spaced by what's in it rather than by a gap, so a description with
nothing in it takes no room, and a control beside the field lines up
with its bottom edge.
*/
slab-combobox::part(description) {
color: var(--ash);
display: grid;
font-size: 0.875rem;
}
slab-combobox > [slot='description'] {
margin-block-start: 0.375rem;
}
slab-combobox::part(validity-message) {
color: var(--ember-deep);
font-weight: 600;
margin-block-start: 0.375rem;
}
slab-combobox::part(validity-message)::before {
content: '■ ' / '';
}
@media (prefers-reduced-motion: reduce) {
slab-combobox::part(input),
slab-combobox::part(textarea) {
transition: none;
}
}
slab-combobox::part(listbox) {
animation: slab-combobox-drop 150ms ease-out;
background-color: var(--paper);
border: var(--border);
box-shadow: var(--shadow);
box-sizing: border-box;
color: var(--ink);
margin-block: 0.5rem;
max-block-size: 18rem;
min-inline-size: anchor-size(inline);
overflow-y: auto;
padding: 0.25rem 0;
}
/*
With "multiple", the tags sit in a row between the label and the input,
rather than inside it, so the input keeps Text Field's fixed height.
*/
slab-combobox::part(tags) {
column-gap: 0.375rem;
display: flex;
flex-wrap: wrap;
}
slab-combobox::part(tag) {
align-items: center;
background-color: var(--paper);
border: var(--border);
border-radius: 0;
color: var(--ink);
cursor: pointer;
display: inline-flex;
font: inherit;
font-size: 0.875rem;
font-weight: 600;
gap: 0.5rem;
/* Below each tag rather than below the row, so no tags take no room. */
margin-block-end: 0.375rem;
padding: 0.125rem 0.5rem;
transition:
background-color 100ms,
color 100ms;
}
/* The cross: what a click does. */
slab-combobox::part(tag)::after {
content: '×' / '';
font-size: 1.125rem;
line-height: 1;
}
slab-combobox::part(tag):hover {
background-color: var(--chalk);
}
slab-combobox::part(tag):focus-visible {
background-color: var(--ember-deep);
color: var(--paper);
outline: 2px solid transparent;
}
slab-combobox::part(tag):disabled {
background-color: var(--chalk);
border-style: dashed;
color: var(--ash);
cursor: not-allowed;
}
@keyframes slab-combobox-drop {
from {
opacity: 0;
translate: 0 -0.375rem;
}
}
@media (prefers-reduced-motion: reduce) {
slab-combobox::part(listbox) {
animation: none;
}
slab-combobox::part(tag) {
transition: none;
}
}
tokens.css
:root {
/* Secondary text. 6.8:1 and 6.9:1 on paper. */
--ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
--border: 2px solid var(--ink);
/* Behind disabled and read-only controls, and hovered rows. */
--chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));
/*
The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
enough for borders, fills and large text, but not always for small text,
which takes "--ember-deep".
*/
--ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));
/*
Orange for small text on paper, and for paper text on it. 5.7:1 and
7.4:1.
*/
--ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
--font-body: var(
--slab-styled-font-body,
'IBM Plex Sans',
system-ui,
sans-serif
);
--font-display: var(
--slab-styled-font-display,
'Zilla Slab',
rockwell,
'Roboto Slab',
serif
);
--font-mono: var(
--slab-styled-font-mono,
'IBM Plex Mono',
ui-monospace,
monospace
);
--ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
--paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));
/* The hard, offset shadow a raised surface casts. */
--shadow: 4px 4px 0 var(--ink);
}
/*
Forced colors, such as Windows' contrast themes, replace every color that
isn't a system color, so ember fills and paper marks all become the same
background, and a checked Checkbox looks like an unchecked one. The palette
becomes the user's system colors instead, which are kept. Ember is the
highlight, the color of what's selected, and ember-deep, being for text and
for paper text on it, is the text color.
*/
@media (forced-colors: active) {
:host {
--ash: GrayText;
--chalk: Canvas;
--ember: Highlight;
--ember-deep: CanvasText;
--ink: CanvasText;
--paper: Canvas;
}
}