Fragiola

Concepts

Part and state attributes

How to select and style every part with data-primitives-part, and its state with data-* and ARIA attributes, the same in every framework.

Every element a primitive renders says which part it is, and its state is attributes: select and style them, never class names the library does not have.

The part attribute

Every element carries data-primitives-part="<component>-<part>":

elementattribute
a dialog's triggerdata-primitives-part="dialog-trigger"
a dialog's popupdata-primitives-part="dialog-popup"
an alert dialog's popup (Dialog's part, named by its root)data-primitives-part="alert-dialog-popup"
a context menu's item (Menu's part, named by its root)data-primitives-part="context-menu-item"
a tabdata-primitives-part="tabs-tab"
the tab indicatordata-primitives-part="tabs-indicator"
a combobox's hidden inputsdata-primitives-part="combobox-hidden-input"
a calendar's cell, and a range calendar'sdata-primitives-part="calendar-cell", "range-calendar-cell"

One attribute for the whole library, since many components have parts of the same name. Your tests, styles and tools can rely on it in every framework.

State attributes

A boolean state is an attribute that is present (with an empty value) or absent, never "false", so [data-open] and Tailwind's data-open: variant just work.

attributeon
data-openan open overlay (a popup, its positioner, its arrow, a dialog's backdrop and viewport); an open collapsible, accordion item and their parts
data-closeda rendered overlay part that is not open (its exit runs, or the Portal's keepMounted keeps it, hidden); a closed collapsible, accordion item and their parts (with data-open: exactly one is present)
data-panel-opena collapsible's or an accordion's trigger while its panel is open
data-popup-opena trigger while its overlay is open: the active one of several detached triggers only (a Select's, a CascadeSelect's, a date picker's or a color picker popover's trigger, a Combobox's or an Autocomplete's input, input group and trigger too, a context menu's area)
data-starting-stylean element that just mounted, for one frame: transition from it
data-ending-stylean element whose exit animation runs; it unmounts (or is hidden) once its animations end: an overlay, a tabs panel, a collapsible or accordion panel
data-selecteda selected tab and its panel, a selected select, combobox or listbox option, a cascade select's option on the chosen path, a selected tag of a tag group, a selected color swatch picker option, a chosen calendar date
data-checked, data-unchecked, data-indeterminatea checkbox's state (exactly one is present) and its indicator; a switch's and a radio's data-checked or data-unchecked, on its thumb or indicator too; a menu checkbox or radio item's, and its indicator's; a segmented control's item and its text; a rating's star (the one that holds the value is checked)
data-indeterminate, data-progressing, data-completea progress bar's status, on every part (exactly one is present): no value, a value below max, max; data-complete also on every part of an OTP field whose code is complete
data-scrubbingevery part of a number field while its scrub area scrubs
data-readonlya read-only number field's, OTP field's, date field's, time field's or range field's parts (and a read-only calendar or switch); a read-only rating and its stars; a read-only password input's, search field's or editable's parts
data-presseda pressed toggle
data-multiplea toggle group or a listbox with multiple
data-placeholdera Select or a CascadeSelect showing its placeholder; a date or time field's segment with no value; an editable's preview showing its placeholder
data-typea date or time field's segment: its type (era, year, month, day, hour, minute, second, dayPeriod, timeZoneName, literal; a value)
data-emptya combobox's or an autocomplete's list with no item; a command's list with no item shown (once mounted); a tag group's root and list with no tag (once mounted); a tags input's root and control with no tag; a search field's parts and an editable's parts while the value is empty; a file upload's parts with no accepted file
data-editinga tags input's tag while its tag input edits it; an editable's parts while it edits
data-visiblea password input's parts while its text is shown
data-copied, data-faileda clipboard's parts while its last copy succeeded, or failed, until its timeout
data-drop-targeta drop zone, or a file upload's Dropzone and Root (and its parts), while a drag of files is over it
data-rejecteda file upload's Item, and its parts, for a rejected file
data-dragginga slider (a color slider, a color area, a color wheel) while a pointer drags a thumb; a carousel's slides' container while a mouse drags them
data-channela color slider's and a color field's parts, a color area's inputs: the color channel they edit (a value: hue, saturation, lightness, brightness, red, green, blue, alpha)
data-axisa color area's input: x or y (a value)
data-formata color picker and its FormatSelect: its format (a value: hex, rgb, hsl, hsb)
data-indexa slider thumb's value index; an OTP field slot's index; a virtual list's rendered option's index; a carousel slide's index (a value)
data-loadinga virtual list while loading (with aria-busy="true"); a command's list while loading
data-requireda required checkbox, switch, radio group, segmented control or rating, and its radios; every part of a required number field, OTP field, date or time field, or range field
data-invalid, data-valida field that shows an error, or that validated and is valid; data-invalid also on every part of a date, time or range field whose value is out of range or unavailable (a range: or whose end is before its start), and on a typed picker's segments whose complete entry is
data-dirty, data-touched, data-filled, data-focuseda field whose value changed, whose control lost focus once, whose value is not empty, whose control has focus; data-filled also on an OTP field slot that holds a character
data-highlightedthe menu item, select, cascade select, combobox, autocomplete or command option the keyboard or the pointer points at; a listbox's focused option; a rating's star drawn filled, whole or half (by the value, or the pointer's preview)
data-halfa rating's star drawn half filled
data-instanta tooltip that opened with no delay (focus, or a hand-off in its group); a hover card moved to another of its triggers
data-expandeda toast viewport and its toasts while the pointer is over it or the keyboard is in it; a cascade select's parent option while its level is open
data-has-childrena cascade select's parent option (an item with children)
data-deptha cascade select's level: its depth, 0 for the first (a value)
data-limiteda toast queued past the limit (with inert)
data-swiping, data-swipe-directiona toast while a swipe moves it, and the direction it moves in (a value); a drawer's popup
data-typea toast's type, on its parts (a value: loading, success, error, or the app's own)
data-prioritya toast viewport's live region: low (polite) or high (assertive)
data-has-overflow-x, data-has-overflow-ya scroll area whose content is wider (taller) than its viewport, on its root, viewport, content and scrollbars
data-overflow-x-start, data-overflow-x-end, data-overflow-y-start, data-overflow-y-enda scroll area scrolled away from that edge (the x edges logical: the start is the right edge in RTL)
data-scrollinga scroll area's parts while the user scrolls it (a scrollbar and its thumb: their own axis)
data-hoveringa scroll area's scrollbars while a mouse or pen is over its root
data-currenta pagination item of the current page (with aria-current="page"); a link or a breadcrumbs link to the current page; the current step's parts (with aria-current="step" on its item and trigger) and its content; a carousel indicator of the current page
data-completed, data-incompletea step's parts before or after the current step (data-completed on every step, and on the steps root, once the process is completed)
data-inviewa carousel slide on the current page (the others are inert)
data-playing, data-pauseda carousel and its autoplay trigger while the slides rotate; a carousel while a hover pauses the rotation
data-nesteda submenu's positioner and popup; a nested dialog's popup, backdrop and viewport (a dialog or alert dialog inside another's popup)
data-nested-dialog-opena dialog's popup, backdrop and viewport while a dialog nested in it is open
data-sidethe side a positioned overlay ended up on (a value: top, bottom, inline-start, inline-end, left, right, named as it was asked)
data-alignstart, center or end (a value)
data-disableda disabled part
data-orientationhorizontal or vertical (a value): tabs, an accordion, a slider, a radio group given an orientation, a separator, a toggle group, a toolbar and its parts, a menubar, a scroll area's scrollbar and thumb, a segmented control and its parts, the steps' parts, a carousel and its slides' container and indicator group, a color slider and its parts
data-activationautomatic or manual on tabs (a value)
data-activation-directionwhere the newly selected tab sits from the previous one, on every tabs part (a physical value: left, right, up, down, none)
data-today, data-outside-month, data-unavailablea calendar cell of today, of another month's day, of a date the app marked unavailable
data-range-start, data-range-end, data-in-range, data-range-previewa range calendar's cells: the range's ends, its dates, the dates of a range being chosen
data-readonlya read-only calendar, a read-only switch and its thumb

One CSS variable carries the depth of nested dialogs: a dialog's popup has the inline style --nested-dialogs: <n>, the number of open dialogs nested below it as a chain (0 when none), to scale or offset the parent (scale: calc(1 - 0.05 * var(--nested-dialogs))).

A scroll area writes what it measures: its viewport's --scroll-area-overflow-x-start, -x-end, -y-start and -y-end (the distance to each edge, for a fade), its scrollbars' --scroll-area-thumb-height / --scroll-area-thumb-width, and its root's --scroll-area-corner-width / --scroll-area-corner-height.

A segmented control's indicator carries its checked item's box, from the root's padding box: the logical --segment-indicator-inset-inline-start, -inset-block-start, -inline-size and -block-size, and the physical --segment-indicator-left, -right, -top, -bottom, -width and -height.

A toast carries its place in the stack: --toast-index, --toast-offset-y, --toast-height and the swipe's --toast-swipe-movement-x / -y, with the viewport's --toast-frontmost-height.

ARIA carries the rest: aria-live (a toast viewport's live regions), aria-expanded, aria-selected, aria-checked, aria-pressed, aria-invalid, aria-activedescendant, aria-modal, aria-controls, aria-current, aria-readonly, aria-valuenow, aria-valuetext, aria-busy, and a virtual list's aria-setsize and aria-posinset.

An enter and exit transition

[data-primitives-part="dialog-popup"] {
    transition: opacity 150ms, scale 150ms;
}
[data-primitives-part="dialog-popup"][data-starting-style],
[data-primitives-part="dialog-popup"][data-ending-style] {
    opacity: 0;
    scale: 0.95;
}

The popup stays mounted while its exit transition runs, and unmounts when it ends (or, with the Portal's keepMounted, is hidden with data-closed). onOpenChangeComplete(open) reports the end of each transition.