Document tabs

The tabs of open documents (an editor's, a browser's): closable, with an unsaved mark, all over one shared panel; WAI-ARIA tabs with arrows, Home/End and Delete to close. The app closes them: ray-request-close asks.

Source on GitHub

GETList releases POSTCreate release DELETEDelete asset

Click a tab or use ←/→; × (or a middle click, or Delete on the focused tab) closes it. Closing the unsaved one asks first. The tabs share one panel, filled for the selected request.

Code

API

For AI agents: this API as Markdown, or every component in llms-full.txt.

<ray-doc-tabs>

Unlike ray-tabs, a tab has no panel of its own: they all control the element named by panel, whose content the app fills for the selected one. Closing is the app's: the ×, a middle click or Delete/Backspace fire ray-request-close, and the app removes the tab (after asking about unsaved changes, if it must). When the selected tab is removed, the one at its place is selected (change) and, if the closed tab had the focus, focused. More tabs than width: the bar scrolls sideways, fades the edge that hides tabs (data-overflow-start / data-overflow-end on the host), scrolls with a vertical wheel and keeps the selected tab in view.

PropertyAttributeTypeDefaultDescription
valuevaluestringValue of the selected tab (default: the first).
panelpanelstringThe id of the shared panel: it gets role=tabpanel and aria-labelledby the selected tab; the tabs get aria-controls.
labellabelstringAccessible name of the tab list ("Open requests").
closeLabelclose-labelstringClose (text doc-tabs.close)Tooltip of the ×.
dirtyLabeldirty-labelstringUnsaved changes (text doc-tabs.dirty)What assistive technology hears after the name of a dirty tab.
EventDescription
changeThe selected tab changed: a click, the arrow keys, or the selected tab removed.
ray-request-closeThe × was clicked, the tab middle-clicked, or Delete/Backspace pressed on it: remove the tab to close it (not fired for hide-close tabs).
SlotDescription
(default)ray-doc-tab elements.
endAfter the tabs, outside the scrolling list: a new-tab button.
PartDescription
listThe tab list (it scrolls sideways when the tabs do not fit).
endThe end slot's box.

<ray-doc-tab>

A document's tab: an icon or tag (slot left), its name (cut with an ellipsis; give the full one in title), and the × or the unsaved dot.

PropertyAttributeTypeDefaultDescription
valuevalue reflectsstringIdentifies the document (ray-doc-tabs value).
dirtydirty reflectsbooleanUnsaved changes: a dot in place of the ×, which comes back under the pointer.
hideClosehide-close reflectsbooleanCannot be closed: no ×, no middle click, no Delete.
SlotDescription
(default)The document's name.
leftAn icon or a tag (a file type, an HTTP method).
PartDescription
labelThe name.
left-sectionThe left slot's box.
closeThe × (pointer only: it is not focusable).
dotThe unsaved mark.

Texts

What it writes itself, in English; setStrings() translates them (Getting started: Languages).

KeyEnglish
doc-tabs.closeClose
doc-tabs.dirtyUnsaved changes