Rules for components that compose several Carbon elements, such as grids, trees, editors, boards, pickers and overlays. CONTRIBUTING.md applies to all code in this repository and takes precedence over this file.
- Principles
- Styles
- API
- Keyboard and accessibility
- Motion
- UI text
- Icons and pictograms
- Async states
- Timing
- Svelte
- Design checks
- Performance checks
- Pull requests
- Match Carbon's design. Where this library can improve behavior, developer experience or speed, improve it.
- Carbon React's behavior is evidence, not the rule. Where it contradicts the WAI-ARIA APG or these guidelines, follow them and say so in the pull request (for example, disabled menu items stay focusable).
- If a rule, test or budget blocks a better design, change the rule in the same pull request and give the reason.
- Add no runtime dependencies. Ship optional code from a separate entry point, as
carbon-components-svelte/syntaxdoes. - Support performance claims with measurements, for example "1.5 ms per arrow key at 10,000 rows; 6 ms at 4x CPU throttling".
- Build the smallest version that tests the design. List what is deferred and why.
Before you write CSS, look for a Carbon block whose rules you can use unchanged. Use a class only if you want all of its rules.
- Grids and tree tables: use DataTable's classes and its
headersshape. Write row headers as<td role="rowheader">so DataTable'stdrules for padding, zebra, hover and selected state apply. A<th scope="row">needs all four restyled. - Lists in a panel: use the ListBox classes. The menu classes are for a popup (absolute position, shadow, hidden until open). Override the position in the component's partial.
- Anchored panels: use Popover or Toggletip. Their caret centers on targets of any size.
- Drawers and full-height overlays: use the dialog lifecycle, scroll lock and focus trap from SidePanel and the modals. Use ActionSet for the buttons.
- Page and table toolbars: use DataTable's Toolbar layout (
bx--table-toolbar). Items fill the toolbar's height with no inner padding, and a search field's bottom border is the toolbar's bottom edge. A toolbar inside a field, such as a text editor's, keeps field-sized buttons and leaves the field's focus ring visible. - Content surfaces: use
LayerandTile. For content, useTag,UserAvatarandOverflowMenu. - If a component includes parts you do not need (Slider renders a label row and a number input), import its helpers and custom properties instead of the component.
- Fix a bug in a reused class at its shared rule, not in a copy scoped to your component. A scoped copy leaves every other user of the class broken. SelectionBar patched batch actions' icon fill and RTL gap under
.bx--selection-bar; #5888 fixed the shared rules, and the copies became dead code.
Custom styles in CONTRIBUTING has the full list. Summary:
- Use the
bx--BEM classes in markup. - Use theme tokens for color (
$layer,$text-primary). The$ui-01-style names failtests/css/v11-tokens.test.ts. - Use contextual color tokens (
$layer,$field,$border-subtle) so a surface changes with itsLayer. *-selected,*-hoverand*-activetokens mark states. Do not use them as surface colors.- Show a status (error, warning, success, info) with one color everywhere it appears in a component. Pair the color with a cue that does not depend on color: text or a shape. Do not add a second badge or icon for the same status.
- Categorical colors, such as event or tag categories, use a fill and one accent (a bar or a dot) in the same hue. Add a border only under
forced-colors: active, where fills disappear. - Search matches use
$highlight. The current match adds a 2 px$focusoutline. Do not reuse a style the content can produce itself, such as inverse text. - Sizes:
to-rem(Npx)or$carbon--spacing-01to-13. Borders and outlines of 1 or 2 px stay inpx. - Type:
type-style("…"). Motion:$duration--*withmotion(…). - List each transitioned property. Do not transition the focus ring.
- Stacking above the page:
z("floating")and related keys. - Custom properties that this library adds use the
--ccs-*prefix. Use a theme token if one exists. If none fits (there is no text-safe yellow or orange), use Carbon palette values, one set for light themes and one for dark.
- Use the spacing scale for all gaps, padding and sizes: 2, 4, 8, 12, 16, 24, 32, 40, 48 px and up.
- The gap between groups is at least twice the gap between items in a group, measured between visible content (text and icon ink), not between element boxes. Do not use one gap for every item in a row.
- Columns of monospace content (line numbers, timestamps, levels, ids) have fixed widths in
ch, so values line up across rows. Achwidth does not include letter spacing, and Carbon'scode-01andcode-02styles add 0.32 px per character. Setletter-spacing: 0on those columns. - Use the row heights of the most similar component's size family: DataTable sizes for grids, ListBox sizes for fields. Accept the family's aliases.
- Repeated rows of one shape have one pitch, and it is a multiple of 4 px. Rows with optional or wrapping content share one minimum height and one padding instead. Rows that overlap by 1 px to share a border move 1 px off the grid per row.
- A grid uses at most two line styles, for example hour lines and day lines, both
$border-subtle. Show extra guide lines only during an interaction such as a drag. - Rows of form fields use fixed widths for every column except the last, so fields line up across rows. Only the last column grows.
- Columns in a board or a grid keep their width when content changes. Set a fixed or minimum and maximum width; long content wraps or truncates inside the column. A column that shows numbers, dates or ids is at least as wide as its widest value; it grows past a consumer's width before it cuts a value.
- Parts that move inside a component, such as slider thumbs and drag handles, stay inside the component's box at every value.
- Content outside a fixed range, such as a bar past the end of a time axis, is clipped at the range edge and marked as continuing.
- Decorative layers (highlights, overlays, rings drawn with pseudo-elements) set
pointer-events: noneso they never take a click. - Room reserved for a control (copy, close, clear, toggle) goes when the control is hidden or moves elsewhere. Left in place, it stops text short of the edge, and in a code area, whose padding is physical, it turns into a visible indent under
dir="rtl". Detect the control with:has()or a modifier class the component already sets (#5887, #5894). - Show nesting with an indent and a 2 px inline-start rule (
$border-subtle). Do not put a bordered box inside another bordered box. Nested levels then share the outer level's inline-end edge. - Page-level surfaces use
$background, with fields on$field. Panels and narrow overlays use$layer.
Align what the eye sees: the ink of glyphs and icons, and text baselines. Element boxes include padding that the eye does not see.
- Content in a toolbar or header starts at the same inline edge as the rows below it. The first icon's visible edge and the first character of the first column share one x.
- Centered content aligns on a shared center axis. A centered column header and the centered value below it, such as a weekday and its date in a circle, share one center.
- Icons side by side have the same optical size. Draw them on the same artboard (16 px) with a similar ink extent. A letterform icon such as "Aa" that fills less of its box reads smaller than an arrow beside it.
- Text in adjacent controls of one row shares a baseline. In a flex row with mixed type sizes, use
align-items: baseline. Align on the baseline only when every item starts with text. An item that starts with an icon takes its baseline from the icon; align those rows to the top. - Text the user writes (log lines, messages, editor paragraphs, search queries) reads in its own direction on a page of the other direction. Blocks of text get
dir="auto". Text inputs getunicode-bidi: plaintext, which keeps the field's padding and icons on the page's sides. - Center an icon on the cap height of the text beside it. A 16 px icon next to
body-compact-01text centers in the 18 px line, which lands within 0.4 px of the cap height. Inline in running text,vertical-align: middlecenters on the x-height instead, about 0.09 em low in IBM Plex Sans. Lift the icon with a negativetopon a positioned element, which keeps the line box. CheckexpectAlignedwithedge: "cap-center", and check icons whose weight sits to one side, such as Copy, on a 2x screenshot. - Fields in a row align to the top of their field box. A message under one field does not move its neighbors. To center a shorter control, such as a toggle, center that control; do not center the field wrappers.
- Align numbers by place value: right-align numeric columns and use
tabular-nums. - Check alignment on a 2x screenshot. Edges that should line up differ by at most 0.5 CSS px.
- Use the productive type styles in components:
body-compact-01for UI text,label-01for labels and helper text,heading-compact-01and-02in panels,code-01and-02for code. Use expressive styles only on marketing-style surfaces. - Text is at least 12 px (
label-01), including tags, counts, timestamps and stand-in content such as Flag's code box. Where 12 px text can't fit, show no text and keep it in the accessible name and atitle. The code box set 7 to 11 px text at 16 to 24 px wide until #5380. - Numbers that change or stack in a column use
font-variant-numeric: tabular-nums. Right-align numeric columns. Wrap a formatted number in<bdi>with the direction of the locale that formatted it. - Use the monospace family for values people copy or compare: ids, hashes, keys, paths, versions, log lines.
- Each text slot either wraps or truncates, and the component documents which. Labels, menu items and error messages wrap. Single-line cells and tags may truncate. Error messages never truncate.
- Use
text-wrap: balanceon headings andtext-wrap: prettyon body text. - Body text in long descriptions is at most about 70 characters per line, about 480 px of
body-compact-01. A70chwidth holds about 88 characters of IBM Plex Sans, so set the width in px or rem. - Show an empty value as an em dash with an accessible name ("None"). Do not leave a cell blank.
- Join a number and its unit with a non-breaking space: "12 GB".
- Change layout for narrow screens with CSS breakpoints. Do not change state, such as a view, a page size or
open, from the viewport width in JavaScript: the server cannot know the width, and the change overwrites a bound prop. - A component that changes layout by its own width uses a container query on itself, not a viewport breakpoint, so it lays out the same in a 20rem panel on a wide screen as on a phone. Pagination and ActionSet do. A set of actions that can't fit its labels stacks or wraps; it does not squeeze them.
- Give a container query fixed widths, not breakpoints estimated from the content, such as one per action count.
container-type: inline-sizestops the box from sizing to its content, so the docs say that a parent that sizes to its content needs a width. Browsers without container queries (Safari 15.4) get a plain layout that works without them. SelectionBar flattens its actions below 672 px and keeps a wrapped list otherwise (#5883). size,kind,invalid,warn,disabled,readonly, skeletons andLayerwork as in related components. Form controls passtests/form-field-contract.- A field's look is
variant:"default","fill"(no bottom border) or"ghost"(no border, and no fill until hover or a value). A field drawn on another surface, such as a toolbar's search, uses one of these looks, not rules of its own. A look that drops a border makes ittransparent, so the field keeps its height and forced colors still draw the edge. - A disabled component shows every part as disabled: text in
$text-disabled, icons in$icon-disabled, no hover, and no focus on its items. It disables its own controls; for slotted content, it setsinerton the slot region or documents that the consumer disables it. A read-only component keeps its text color and blocks changes. An unavailable item inside an enabled composite (a menu item, a toolbar button) is a different case: it stays focusable witharia-disabled. - Where an alignment rule conflicts with the built-in layout of a Carbon component used inside, such as a field label's position, keep the Carbon layout and say so in the pull request.
- Overlays move to a portal when a container would clip them. A container with a
transformorcontent-visibility: autoalso clips in-place menus. SetportalMenuon menus inside one. - Do not size an overlay or a panel with
100vw: it includes a classic scrollbar, so the box runs under it. Use100%of the containing block. - A titled surface uses
Sectionone level below the page, so its headings nest.
- Data in, no mutation. Take arrays and objects as props. Assign new values; do not edit the consumer's objects. Return changes through
bind:. Examples:rowsandselectedRowIdson DataTable,nodesandexpandedIdson TreeView. Do not change a bound value on mount. Ids the component cannot resolve yet, such as checks under a node that has not loaded, stay in the value until their data arrives. - Data array with a per-item slot for collections that need search, filtering, virtualization or reordering. A child component per item cannot be sorted or virtualized. Use child components for other cases. See Code style.
- Cancelable events for user actions. Dispatch moves, pastes, sorts and closes with
{ cancelable: true }, synchronously.preventDefault()cancels the action. Example:click:overflowon TagSet. - Exported helpers. Put logic that consumers may need without the component (serialize, validate, evaluate, apply a change) in a pure function with no DOM access, exported from the package. It must run on the server. Examples:
toCsv,toHierarchy,fuzzyMatch. - Actions for consumer markup. Components cannot take actions. Put the action on a wrapper element and select the items inside it. Examples:
rovingFocus,dismiss. - Strings as props. Every visible or announced string is a prop. Reuse the name and signature from a related component (
*Textprops,translateWithId). A component withtranslateWithIdresolves the prop, then the function the app set once withsetTranslateContext, then its English default; a function that returns no value for an id keeps the English text. Every English default is listed ini18n/strings.json, whichbun run build:stringsregenerates, andtests/i18n/hard-coded-english.test.tsfails on literal English left in markup. - Enums for variants (
selectionMode,size,kind). Use a boolean only for a true on/off state. A look is an enum even when it starts with two forms, because more follow: Search hasvariant="ghost", notborderless. idprop. Default it touseId("component-name"), and derive inner ids from it. A parent whose children take their own default ids starts a scope withcreateIdScope(id). Do not build ids from consumer data: a space in an id breaksaria-activedescendantandaria-controls. Use the item's index. List each derived id a consumer may target (a label'sfor,aria-controls,returnFocusTo) in theidprop's JSDoc, and add it to the contract test beside the IdScope sweep, which fails when a listed id goes missing (#5891). Other derived ids are internal and may change.- No writes to props. Store measured values in internal variables.
$$restPropsgo on the primary element; for a form field,classandstylego on its root, so layout classes such as margins affect the whole field. A consumeraria-labelreplaces the defaultaria-labelledby.
These names apply to new components and new props. Shipped components keep their names; do not rename existing props without keeping the old name as an alias.
| Kind | Name | Examples |
|---|---|---|
| Visible text | {part}Text |
labelText, helperText, emptyText |
| Text read only by assistive technology | {part}Description |
iconDescription, loadingDescription, badgeDescription |
| Assistive text built from values | {part}Description as a function with a named default |
countDescription(count, limit) |
Text both shown (in a title or tooltip) and read |
{part}Text, or a {part}Text function |
colorNameText(color) |
| Text for each state of a two-state control | one *Text prop per state |
onText, offText |
| Text built from values | {part}Text as a function with a named default |
pageRangeText(start, end, total) |
| Heading of a surface | titleText |
A title prop also sets the native title attribute through $$restProps |
| On/off state | an adjective | open, expanded, disabled, readonly, invalid, loading |
| Visual hiding | hide{Part} |
hideLabel |
| Name for a part with no visible label | labelText with hideLabel |
A list title that only screen readers hear |
| One of several forms | a string enum | kind for meaning, size for scale, variant for look |
| Field look | variant: "default", "fill" or "ghost" |
Search; ToolbarSearch uses "ghost" |
| One selected item | selectedId |
|
| Several selected items | selectedIds, expandedIds, checkedIds |
|
| Form value | value |
|
| Collection | items (list), nodes (tree), rows and headers (table) |
|
| Size of a collection that is only partly loaded | totalItems, -1 when unknown |
Pagination, VirtualList |
| Shape of a box | ratio: a named ratio or "WxH" |
AspectRatio, CardMedia, TileGrid |
| Map from an item | itemTo{Thing} |
itemToString, itemToId |
| Decision callback | should{Verb} returning a boolean |
shouldFilter |
| Placement | align, in floating-ui form |
"bottom-start", "end" |
| Class on a floating box | tooltipClass on a tooltip, in place and in a portal; popoverClass on a popover |
Button, Toggletip (#5892) |
| Side of a part beside another | "start" or "end", never "left", "right" or "inline" |
Toggle's labelPosition="end" |
- Fields of data items follow the same names as props. A TreeView node's
badgeDescriptionis what screen readers hear for itsbadge. - Use
openfor content that floats above the page (menus, popovers, modals, panels). Useexpandedfor content that pushes the page (disclosures, tiles, tree rows). - Do not use negative booleans (
prevent*,no*). Name the behavior:closeOn={["escape", "outside"]}. - Do not select by index. An index changes when items are sorted, filtered or reordered.
- Internal booleans are adjectives (
open,focused). Reserveisandhasfor functions.
- Name the main state change with a verb in the present tense:
change,select,open,close,toggle,expand,collapse,sort,move,remove. Dispatch it before the change when it can be canceled. - A component with more than one bindable value dispatches
{noun}:changefor each, with the noun in kebab case:active-cell:change,selection:change. - An event from one inner element is
{event}:{part}, with the part in kebab case:click:row,mouseenter:trigger. - A failure is
{action}:error:copy:error,download:error. detailis always an object:{ id, item }for items,{ trigger }for open and close,{ from, to }for moves. Close triggers use the values the library already sends:"escape-key","outside-click","close-button","programmatic".
- A slot that replaces a prop's content is
{prop}Children:labelChildren. Slot names are camelCase so they map to Svelte 5 snippets. - Position slots use logical sides:
{part}Start,{part}End. actionsholds a group of buttons.actionholds exactly one.- A slot inside a wrapper element hides the wrapper with
:empty { display: none }. Svelte can't wrap a slot in{#if}, and$$slots.xis true once the consumer passes the slot, even when its content renders nothing. Keep whitespace text out of the wrapper so:emptymatches (#5883, #5893). Test it as described in What to test. emptyrenders when there are no items.noResultsrenders when a filter matches none. A component with both states has both slots.- A slot for a custom trigger passes one object to spread on it, such as
let:triggerPropswith itsid,aria-*attributes and handlers. - A text slot inside a flex row, such as a link, button or menu item, renders in one wrapper element (
__label,__text,__link-content). Without it, each icon, tag and text run in the slot is a separate flex item: they touch, an icon shrinks when the text wraps, and a tag truncates. Give the wrapper a gap,flex-shrink: 0on icons and tags, andalign-items: flex-startso they line up with the first line of wrapped text. - Slot content inside a link or button must not be interactive: a nested link or button is invalid HTML. The docs say so in the component's usage table. An icon in the slot that shows status, not decoration, gets a
titleso it adds to the control's name.
| Use a data array and a per-item slot when | Use child components when |
|---|---|
| The count is large or unbounded | The count is small and fixed |
| Items need search, filtering, sorting, virtualization or reordering | Items keep the order of the markup |
| Data comes from a server and selection is by id | Items are written by hand |
| Items have one shape | Each item is different |
| The server render must show the final state | The consumer controls layout between items |
- Combine them where it helps: a data array with a per-item slot (
let:item), or a data array withitemTo*accessors so consumers do not reshape their data. - Child components that register with a parent batch the registration (
batchStoreUpdates). Their first-render state comes from props or$$slots. - Use separate props for a few independent values (
primaryButtonText,primaryButtonDisabled). Use an object when the values come from data together (headers). Use a slot when a group grows past about three related props. - More than about 25 public props means the component should split into parts.
- Choose a WAI-ARIA APG pattern before you write markup. Document each deviation and its reason.
- Use native elements where they fit:
button,a,input,select,dialog. - Do not put a
roleon aulorolwhose children stayli. The role replaces the list, so screen readers drop the item count, and axe flags eachli(listitem). Name a list witharia-labelledby. - Give every control an accessible name. Connect helper and error text with
aria-describedby; join multiple ids with spaces. - Expose state with
aria-expanded,aria-selected,aria-checked,aria-pressed,aria-current,aria-invalidandaria-busy. - Use
aria-disabledfor items that must stay focusable while unavailable, such as menu items and toolbar buttons. Ignore their activation in the handler.
- A composite widget (listbox, grid, tree, toolbar, tablist, radio group) has one tab stop. Arrow keys move focus inside it.
- Use roving
tabindexwhen items receive DOM focus. Usearia-activedescendantwhen focus must stay in a text input, as in a combobox. - Do not add
tabindex="0"to native buttons and links so Safari's Tab reaches them. Safari skips them unless the user turns on "Press Tab to highlight each item" or presses Option-Tab, and that choice is theirs. Button keeps itstabindex="0"default only for parity with Carbon React. An e2e test that counts Tab presses branches for WebKit. - Every focusable element shows the focus ring from
@include focus-outline("outline"). - The focus ring follows the keyboard. Hover and clicks draw fills, never the ring. A region that takes focus only so the keyboard can reach or scroll it (a tab panel, a wide table, a log) rings on
:focusand drops the ring on:focus:not(:focus-visible), so a click on its text leaves it plain. Do not move focus after a pointer click unless Carbon React does.pointer-focus-ring.test.tschecks this on every fixture. - When you port a v11 rule tied to a state (
--highlighted,--selected,:focus), find when Carbon React sets that state, and match it. React's Downshift reducer ignores hover, so its--highlightedring only follows the keyboard. - Opening a dialog or panel moves focus into it. Closing it returns focus to the trigger, or to a documented fallback if the trigger was removed.
- A component that returns focus takes
returnFocusTo, an element or a function, with one meaning everywhere: when it resolves to an element, focus goes there, over the trigger; when it resolves to nothing, focus returns to the trigger (#5873, #5890). - After an item is removed, move focus to the next item, then the previous item, then the container.
- Do not move focus on hover, on timers or on data updates.
- A component that opens itself, such as a coachmark on page load, does not move focus. It moves focus only when the user opened it.
| Key | Action |
|---|---|
| Arrow keys | Move one item. In a 2D grid, move one cell. Left and Right swap under dir="rtl". |
| Home / End | First / last item. In a grid, first / last cell in the row; with Ctrl, first / last cell in the grid. |
| Page Up / Page Down | Move one visible page in long lists and grids. |
| Enter | Activate the item, or open it. |
| Space | Toggle selection or a checkbox; activate a button. |
| Escape | Close the innermost open layer and return focus to its trigger. Clear a filter only if nothing is open. |
| Printable characters | Type-ahead to the next matching item (typeahead.js). |
| Shift + arrow keys | Extend a multiple selection. |
| Ctrl/⌘ + A | Select all, in multiple selection only. |
- Do not bind single-character shortcuts at the document level (WCAG 2.1.4). Use
keyboard-shortcut.jswith a modifier, and scope shortcuts to the focused component unless they are documented as global. - Check a list of shortcuts one entry at a time. In
["mod+k", "/"],/still types in a text field, andmod+kworks there (#5877). - Every drag operation has a keyboard alternative and a single-pointer alternative (WCAG 2.5.7).
- A component that uses Tab itself, such as a text editor indenting a list, gives a documented way out (Escape, then Tab).
- Announce results and status with
aria-live="polite". Useassertiveonly for errors that block the user. - Announce each change once. Throttle announcements for streams.
- Send announcements through the shared announcer (
createAnnouncerChannelinannouncer.js), not a live region of the component's own. It puts the message inside an open modal dialog the component is in, where a region in the body is out of the accessibility tree. - Text contrast is at least 4.5:1. Large text, icons, focus rings, selected indicators and borders that identify a control or show its state are at least 3:1 (WCAG 1.4.3, 1.4.11). Borders that only divide the layout, such as dividers and nesting rules, may use
$border-subtle. - The component works at 200% zoom and at a 320 px CSS width (WCAG 1.4.10).
- Keyboard only, for every feature.
- VoiceOver with Safari. For new ARIA patterns, also NVDA with Firefox or Chrome.
- An
e2e/a11y-<component>.test.tsthat runs axe through@axe-core/playwrighton each state. Axe checks only what the fixture renders, so the fixture shows every structure the component can make: groups, nesting and each size.
- Components do not animate by default. Add motion only when it shows something the user would otherwise miss:
- where an element enters or leaves (a panel opens, a row expands);
- that an action completed (a copy confirmation);
- that work is in progress (a loading indicator).
- Do not animate initial render, hydration, data updates (sort, filter, new rows) or decoration.
- A looping animation, such as a pulsing beacon, stops after at most 5 seconds or a few cycles, and stops at once under
prefers-reduced-motion(WCAG 2.2.2). - Measure in a
ResizeObservercallback and write in the next frame (createFrameJob), so a resize does not trigger a ResizeObserver loop error. - Durations come from the motion tokens:
$duration--fast-01(70 ms),fast-02(110 ms),moderate-01(150 ms),moderate-02(240 ms),slow-01(400 ms),slow-02(700 ms).@carbon/motionis the source of truth; the vendored v10 Sass setslow-02to 720 ms and is corrected to 700 ms.- Color, icon and small state changes:
fast-01orfast-02. - Menus, expanding rows and small panels:
moderate-01ormoderate-02. - Full-height panels and modals:
slow-01at most.
- Color, icon and small state changes:
- Easing comes from
motion(standard | entrance | exit, productive). Useentrancefor elements that appear andexitfor elements that leave. Useexpressiveonly on marketing-style surfaces. Where the Carbon component it mirrors usesexpressive, match Carbon. - Animate
transformandopacity; they do not trigger layout. Animate a size only on the one element that expands. - Elements that move together use the same duration and easing.
- Transitions are interruptible. A close during an open reverses from the current position.
- Do not depend on
transitionendto finish a state change. It does not fire when the duration is 0 or the element is hidden. Use a timeout fallback. - Under
prefers-reduced-motion: reduce, remove movement: set durations to 0 for transforms, slides and smooth scrolling. Loading indicators may keep moving, since the motion shows state. - Motion started from JavaScript (
scrollIntoView({ behavior: "smooth" }), the Web Animations API, View Transitions) checksmatchMedia("(prefers-reduced-motion: reduce)"). CSS media queries do not apply to it.
Rules for motion that Svelte's transition:, in:, out: and animate: directives run. The CSS rules above still apply to what the transition animates.
- Components animate only through an opt-in
transitionprop typedundefined | boolean | Params | (Params & { fn }), defaultundefined(off).trueplays the component's Carbon preset, an object overrides the preset's params, andfnswaps in any Svelte transition. Resolve the prop withresolveTransitionfromsrc/motion/; do not read it in the markup. - Presets use the transitions in
src/motion/(fade,slide,fly,flip), which take their durations fromduration(the JavaScript mirror of$duration--*, parity-tested against the Sass) and pick theentranceorexitcurve from the direction. Do not import fromsvelte/transitionin a component. - No directive when off. Svelte 3 and 4 remove an element that carries a
transition:directive one frame late, even at zero duration. Branch the markup:{#if animated}<div transition:fn={params}>…</div>{:else}<div>…</div>{/if}, and share the inner markup through an internal component when it is more than a few lines. Nothing waits on a transition event whenanimatedis false. |localgoes on the block that toggles the element. An ancestor's{#if}suppresses a local transition, so a nested{#if animated}inside{#if open}plays nothing; flatten it to{#if open && animated}…{:else if open}…{/if}.|globalgoes on a root the consumer mounts and unmounts ({#if saving}<InlineLoading transition />{/if}), so the exit plays. Svelte 3 ignores the modifier; 4 and 5 honor it. When that root also sits inside the component's own{#if open}, nest the branches,{#if open}{#if animated}…{:else}…{/if}{/if}: the flat{#if open && animated}form leaves the element in the DOM on Svelte 3 and 4 when the parent removes the component in the sameclosehandler that setsopentofalse.- Finish a state change on
outroend(hidePopover(), pruning a queue entry, returning focus), never ontransitionend, and only whenanimatedis true. - Under
prefers-reduced-motion: reduce, a transition returns exactly{ duration: 0 }with nocss,tickordelay, so Svelte 5 never callselement.animate()and 3 and 4 inject no keyframes. Loading indicators passreducedMotion: "ignore". Read the preference throughshouldReduceMotion(), which shares oneMediaQueryListand returnsfalseon the server. - A
transition:directive passes{ direction: "both" }on Svelte 3 and 4 and resolves a function-form config once, afterwait(), when the outro group is gone. Return a config object, not a function, and use thestandardcurve fortransition:. Usein:andout:where the entrance and exit curves must differ. animate:flipgoes on a DOM element in a keyed{#each}, only where an item leaves and the survivors close the gap. Do not animate a sort, a filter or new rows.- Tests spy on the preset through
vi.mock(import("../../src/motion/transitions.js"))with reduced motion stubbed, and assert exits throughoutroend, since Svelte 3 and 4 call the transition function once per element and reuse its config. A Svelte 5 mount runs the entrance too, so wait it out before testing an exit. Add an e2e row that opens and closes the surface withreducedMotion: "reduce"and assertsdocument.getAnimations()is empty.
Follow Carbon's content guidelines.
- Use sentence case for labels, buttons, headings, menu items and tooltips.
- Buttons and menu items start with a verb: "Delete", "Add rule", "Export as CSV".
- Labels name the value: "Region", "Retention period".
- Placeholders show a format or example. A placeholder does not replace a label.
- Helper text states the constraint in one sentence: "Lowercase letters and hyphens, up to 63 characters."
- Helper text sits below its field, as in Carbon. For a tall group of rows (such as a query builder), it sits under the group's label, before the rows.
- Error text states the problem and the fix: "Enter a port from 1 to 65535." Do not use "Invalid input" or an error code alone.
- Empty states say why the area is empty and give the next action.
- Destructive confirmations name the object and the result: "Delete 3 services? You cannot undo this." The confirm button repeats the verb: "Delete".
- Accessible names for icon-only controls describe the action: "Close", "Remove Austin". Do not include the icon name or the word "button".
- Build text that contains numbers with a function prop that receives the values, for example
pageRangeText(start, end, total). Translators then control word order and plural forms. Do not concatenate strings. - Format numbers, dates, lists and units with
Intl, throughintl-formatter-cache.jsand the component'slocaleprop. - Truncated text keeps the full value available in a tooltip or
title. - When space runs out, drop content in a fixed order: secondary details first (a time, a count, metadata), then shorten the title with an ellipsis, then show no text and keep the full text in the accessible name and a tooltip.
- Never cut a number, date, time or id in the middle. Show it whole or leave it out.
- Consumers pass icons from
carbon-icons-sveltethroughiconprops typedIconComponent. Components use the internal set insrc/icons/. Do not add an icon package dependency. - Use 16 px icons in components. Use 20 px in the UI shell header.
- Color icons with icon tokens:
$icon-primary,$icon-secondary,$icon-on-color,$icon-disabled. Status icons use$support-*tokens. - Hide decorative icons from assistive technology with
aria-hidden="true". This includes icons next to text that says the same thing. - Icon-only controls get their name from
iconDescriptionand show the same text in a tooltip, unless the control opens a popover that shows that text. - Do not show status with color alone (WCAG 1.4.1). Combine color with a shape and text, as
IconIndicatorandShapeIndicatordo. - Use one icon per meaning across the library, for example
Closeto dismiss andTrashCanto delete. - Mirror icons that point forward or back in right-to-left layouts. See Conventions.
- Artwork the library draws, such as flags, keeps the details that identify it at every size. A count wins over a minimum shape size: the US flag had 7 stripes and 9 stars, which reads as another flag, until #5380 drew 13 and 50.
- Use pictograms from
carbon-pictograms-svelteonly for empty states and onboarding, in a slot such asEmptyState'sillustrationslot. They are decorative and hidden from assistive technology. Do not use pictograms as controls or inline with text.
| Situation | Indicator |
|---|---|
| First load of a region | The component's skeleton, at the size of the loaded content |
| Refresh of loaded data | Keep the current content. Set aria-busy="true" on the region and show InlineLoading or a ProgressBar in a fixed slot. |
| Action on one control (save, copy, submit) | InlineLoading in the control, for example Button's loading prop. The control keeps its size. |
| Whole page blocked | Loading overlay. Use it only when no part of the page is usable. |
- Show an indicator only if the operation runs longer than about 300 ms. Once shown, keep it for at least 500 ms. Use
createLoadingDelay(a callback, for aloadingprop inside a component) ordelayedLoading(a store) fromdelayed-loading.js. Button, Dropdown, ComboBox, MultiSelect, Search and SearchMenu takeloadingDelay, wired throughcreateLoadingIndicator; Loading and InlineLoading takedelayand render a waiting spinner hidden, so server HTML holds it. The defaults areLOADING_DELAY_MSandLOADING_MIN_DURATION_MS. A delayed indicator blocks clicks and setsaria-busyat once; only the visual waits. - Reserve space for indicators, status text and error messages so that showing them does not move other content. Field error text replaces helper text in the same row.
- Insert new items without moving the content the user is reading. Keep the scroll position anchored, or show a "Show N new items" control instead of inserting above the viewport.
- Render the loading state on the server when data is not available at render time. Do not replace server HTML with a client-only spinner.
- Give each request an id or an
AbortSignal. Ignore responses for requests that a newer request replaced. Pass anAbortSignalto consumer callbacks that fetch data. - Debounce requests driven by typing with
debounce.js. The input stays responsive while a request runs. - On failure, show the error where the operation failed, with a retry action. Keep the data already loaded.
- Optimistic updates apply at once and roll back on failure with a message. A cancelable event lets the consumer reject a change before it applies.
- While a control is busy, use
aria-disabledand ignore activation, so focus stays on it.disabledremoves it from the focus order. - Announce the result once ("12 results"). Do not announce intermediate states.
Delays and thresholds separate what the user means from incidental movement, and keep the page still while the user acts.
Put every default delay in src/constants/timing.js, named *_MS, with a JSDoc comment that gives the reason. Reuse an existing constant when the purpose is the same.
| Constant | Value | Purpose |
|---|---|---|
TOOLTIP_ENTER_DELAY_MS |
100 ms | Hover or focus time before a tooltip opens |
TOOLTIP_LEAVE_DELAY_MS |
300 ms | Time before a Tooltip closes, so the pointer can move onto it |
TOOLTIP_ICON_LEAVE_DELAY_MS |
100 ms | The same for icon tooltips (WCAG 1.4.13) |
TOOLTIP_SKIP_DELAY_MS |
300 ms | Window after a tooltip closes in which the next one in its group opens with no delay or fade |
SUBMENU_HOVER_DELAY_MS |
150 ms | Hover time before a submenu opens or closes |
SEPARATOR_HOVER_DELAY_MS |
150 ms | Hover time before a Splitter separator highlights |
TYPEAHEAD_RESET_MS |
500 ms | Idle time before a type-ahead buffer resets |
RESULTS_ANNOUNCE_DELAY_MS |
500 ms | Typing pause before Search announces resultsDescription, when debounce is unset |
SUBMENU_AIM_PAUSE_MS |
100 ms | Pause that ends pointer aim toward an open submenu |
LOADING_DELAY_MS |
300 ms | Time loading stays true before an indicator shows |
LOADING_MIN_DURATION_MS |
500 ms | Minimum time an indicator stays once shown |
NOTIFICATION_QUEUE_COLLAPSE_MS |
150 ms | Time before the space a closed toast held under the pointer collapses |
COPY_FEEDBACK_FADE_MS |
110 ms | Fade-out of a copy confirmation, after which it closes if animationend has not fired |
STEPPER_REPEAT_DELAY_MS |
400 ms | Hold time before a stepper button starts to repeat |
STEPPER_REPEAT_INTERVAL_MS |
50 ms | Time between steps while a stepper button stays held |
ANNOUNCER_READY_DELAY_MS |
150 ms | Age a live region reaches before announce() writes to it, so a screen reader has seen it |
ANNOUNCER_CLEAR_AFTER_MS |
7 s | Time an announced message stays in its live region |
DIALOG_CLOSE_MS |
240 ms | Time Dialog stays open for its exit motion |
- Open on hover only after a delay, and close after a grace period. An open and a close cancel each other's pending timer. See
submenu-hover-intent.jsandtooltip-handoff.js. - When one item in a group is already open, open the next one at once (warm handoff). Tooltips do this within
TOOLTIP_SKIP_DELAY_MS. - While the pointer moves toward an open submenu, hold the close and any sibling's open. Recheck when the pointer pauses for
SUBMENU_AIM_PAUSE_MS(pointer-aim.js). - Start a drag only after the pointer moves a few pixels from the press. A smaller movement is a click.
- On touch, open a context menu after a press of about 500 ms with less than about 10 px of movement. Cancel on larger movement so the page still scrolls.
- Run actions on release inside the target. Moving off the target before release cancels the action (WCAG 2.5.2).
- Apply hover delays only to pointers that can hover (
(any-hover: hover)). A tap toggles.
- Show a pressed, selected or busy state within 100 ms of every input, even when the result takes longer.
- Match the indicator to the expected wait:
| Wait | Indicator |
|---|---|
| Under 300 ms | None |
| 300 ms to 2 s | Indeterminate indicator, held for at least 500 ms once shown |
| 2 s to 10 s | Determinate progress or named steps, when known |
| Over 10 s | Progress with an estimate, and a way to cancel or continue elsewhere |
- Delaying the indicator is opt-in per component (Button's
loadingDelaydefaults to 0). Components show it at once by default.
- Do not insert, remove or move content next to the control under the pointer. Hold the change until the pointer leaves the region or the user scrolls.
- While a change is held under the pointer, announce it to assistive technology at once, and show it as soon as the pointer leaves.
- A do-not-disturb mode stops announcements and anything that opens by itself. It still updates counts.
- A counter next to controls ("3 of 12") uses
tabular-numsand reserves the width of its largest value, so the controls after it do not move. - A live list (logs, feeds, notifications) stops following new content when the user scrolls away from the end, and shows a control to return to it.
- A layout that collapses items into an overflow menu collapses at one width and expands at a larger one, so a width near the boundary does not toggle it on every resize. Fields shrink to a minimum width (about 8 rem) before any button collapses, since a field cannot move into a menu. The row never scrolls.
- Debounce requests driven by typing (150 to 300 ms) with
debounce.js. Respond to the first keystroke at once when the work is cheap. - Run scroll, resize and drag work at most once per frame (
raf-throttle.js,createFrameJob). - A held stepper or arrow key repeats after an initial delay of about 400 ms, then at a faster rate.
- Show a field error on blur or on submit. While a field shows an error, check again on every input and clear the error as soon as the value is valid.
- Do not report an empty field the user has not visited until submit.
- A component that sets its own auto-dismiss time makes it grow with the length of the message, with a minimum. Components leave
timeoutto the consumer by default; the docs advise a minimum of about 5 seconds plus reading time for the message, which depends on the language. A notification with an action does not auto-dismiss (WCAG 2.2.1). - Pause auto-dismiss while the pointer is over the notification, while it has focus, and while the tab is hidden (
pause-on-hover-focus.js,timeout-dismiss.js). - For an action the user can reverse, run it at once and offer Undo. Ask for confirmation only before an action that cannot be reversed.
Code style has the general rules: the legacy API on Svelte 3, 4 and 5, script order, class: and style: directives, keyed {#each} over ids, no new afterUpdate, and state per instance.
Check src/utils/ before you write a helper.
| Need | Utility |
|---|---|
| Drag with pointer capture | pointer-drag.js (Splitter, RangeSlider, SidePanel) |
| Element size and visibility | observeResize, observeIntersection in shared-observer.js |
| Batched layout reads and writes | createFrameJob in frame-batch.js (TextArea, Menu) |
| Virtualized lists | VirtualList, virtualize.js, virtual-window.js |
| Roving focus and type-ahead | roving-focus.js, typeahead.js, option-list-navigator.js |
| Search and match ranges | fuzzyMatch, highlightSegments |
| Outside click and Escape | dismiss.js, outside-dismiss.js, is-outside-click.js |
| Dialogs | dialog-lifecycle.js, trap-focus.js, body-scroll-lock.js |
| Text direction and placement | layout-direction.js, inline-align.js, floating-position.js |
| Shared timers and listeners | relative-time-timer-pool.js, window-listener-pool.js |
Intl formatters |
intl-formatter-cache.js |
| Child registration | batchStoreUpdates in batch-store-updates.js |
| Keyboard shortcuts | keyboard-shortcut.js |
| Screen reader announcements | announce, createAnnouncerChannel in announcer.js |
| Ids that match on the server and client | useId, createIdScope in id-scope.js |
| Focus after an item is removed or moved | focusHandoff, captureFocusTarget in focus-handoff.js (TagSet, FileUploader, DataTable) |
| Links in user text | safeUrl in safe-url.js, linkify in linkify.js (LinkifiedText) |
| Data that answers a query | createAsyncSource, createPagedSource in async-source.js (ComboBox's source) |
| Undo and redo | createHistory in history.js |
| Save as you type | createAutosave in autosave.js (SavingStatus's autosave) |
| Wall-clock time in an IANA zone | zonedParts, fromZoned, dayKey in zoned-time.js |
- With pointer capture, the
clickafter a press fires on the capturing element. Read the target inpointerdown. In a draggable item, ignore presses that start on links, buttons and form controls, or those controls stop working. - Svelte 5: if a
$:block assigns a value that an earlier$:block reads, the earlier block does not run again in the same flush. Assign state set by a user action in the event handler. - Svelte 3 and 4:
bind:valuewith a spread on a<textarea>that has text content resets the value. Set the value only throughbind:value. - Svelte 3 and 4: a child that receives
prop={undefined}keepsundefinedand skips its default, such asexport let id = uniqueId(). Pass the prop only when it is set:{...(id ? { id: `${id}-step` } : {})}. Svelte 5 uses the default, so only the Svelte 3 and 4 tests catch it. - A function called in the markup (
{#if},{#each},{@const}, attribute values) that reads component state must receive that state as arguments. Svelte tracks only the names written in the expression, so the function does not run again when the state changes. This fails on Svelte 3, 4 and 5. - A
<bdi>or an element with its owndirresolves logical properties (margin-inline-start,automargins) in its own direction. Put layout margins on its parent. cursororuser-selecton a large container restyles every descendant. Set it on the dragged item, or on an element withcontain.word-break: break-word, which_long-words.scsssets so long words stay in their column, lowers an element's min-content width to one character. A squeezed flex item orautogrid track then breaks a short label such as "Select" a letter a line. Give the item a way to keep its words:white-space: nowrapon a short label,flex-wrapon the row, or a container query that changes the layout.- Text placed directly in a flex or grid container is an anonymous item with
min-width: auto. No rule can select it, sooverflow-wrapon the container does not let it shrink. Wrap the text in an element. - A virtualized list cannot be a live region because rows mount and unmount on scroll. Set
aria-live="off"on the list. Announce summaries from a separate status element, at most once per interval. - Thousands of tags mount slowly. Render a limited number and show the rest as a count.
- A component that measures text, such as an overflow count, measures again once
document.fonts.readyresolves. A web font that loads after the first measure changes the text's width but not the container's, so noResizeObserverfires.
Complete every check before you mark a pull request ready for review.
Measure positions and sizes in the browser (getBoundingClientRect, computed styles). A scaled screenshot gives wrong numbers. An element box does not show where text sits. To find the text, put a zero-height inline-block in the line for the baseline, and use canvas measureText("H").actualBoundingBoxAscent for the cap height. Use getBBox on an icon's paths for its ink. In e2e tests, use the helpers in e2e/helpers/layout.ts (expectAligned, expectOnePitch, expectTextFits, expectNoNestedBorders, expectNoPageOverflow, expectSingleRing); see E2E testing with Playwright.
| Check | Method |
|---|---|
| Carbon spec | Compare with Carbon's spec at the same size and theme. Carbon React's Storybook is a working reference. Record each intentional difference and the reason. |
| States | One fixture shows every size with every state (invalid, warn, disabled, readonly, skeleton, active or current, and hidden label, inline and fluid where the component has them), with one field invalid beside valid ones in the same row, and with zero, one and many items. Review them together. A size's type style can outweigh the state rule, so check the active weight at each size. |
| Themes and layers | White and Gray 100 at minimum. Layer nested to level 3. |
| Right to left | Test with dir="rtl", using sample values that read differently when reversed ("3 / 4", never "3 / 3"),, dir="ltr" and no dir. Forward and back icons mirror. Inline-axis arrow keys swap. Time and progress run toward the inline end. Add a row to e2e/rtl.test.ts. |
| Forced colors | Chromium with forced-colors: active. Draw rings only on the focused or selected item; a ring on every cell hides which one is active. Structural edges, such as a card's 1 px border or a field's resting box, stay: without them a field or card disappears in forced colors. The focus ring is wider than those edges so it stands out. A picture's frame, such as a flag's or a swatch's, is part of the picture, not an edge: the layout sweep's nested-edge check skips images and forced-color-adjust: none elements (#5858). Show selection with a Highlight border; forced colors remove background fills. Draw lines with CanvasText. Draw progress as an element with a system color; forced colors remove background-image. forced-color-adjust: none inherits, so set it on one element only. An item that opts out to paint Highlight and HighlightText sets transition: none in that forced rule. Its background-color or color transition starts from the unforced Carbon color, so for a few frames the selected text is unreadable (#5860, #5861). Add a row to e2e/forced-colors.test.ts. For a state change, read the first frame after it, not a polled final value, as the firstFrames rows do. |
| Narrow containers and long text | 320 px viewport, a narrow panel, and long words, URLs and log lines. Render the component in fixed-width boxes (240, 320 and 480 px) and in rows that shrink: a flex row, and an auto grid track beside minmax(0, 1fr) text. Check both ways: nothing spills past its column, and no word that fits its row is broken across lines. See e2e/long-words.test.ts, e2e/pagination-fit.test.ts and e2e/reflow.test.ts. |
| Adjacent components | Render beside related components at each size. Heights and baselines must align. |
| Consumer overrides | A consumer rule with one class overrides the library rule. See e2e/consumer-override.test.ts. |
| CSS | Run bun run check:css:compare --report <dir> and approve intended changes. Run bun run check:css:size. See Size growth. |
| Check | Method |
|---|---|
| Keyboard | Use every feature without a pointer, following Keyboard and accessibility. Focus stays in the component after a delete, a disable, or a virtualized unmount. |
| ARIA pattern | The pull request names the APG pattern and each deviation. Example: color swatches use listbox because in a radiogroup arrow keys select each swatch they pass. |
| Screen readers | Test with VoiceOver, and NVDA for new patterns. Add a case to tests/aria-forwarding/cases/, or an exemption with the reason. Add an axe test in e2e/a11y-<component>.test.ts. |
| Target size | At least 24 × 24 px (WCAG 2.5.8), or a documented exception. |
| Touch | Works with touch input. Controls that appear on hover also appear on focus, and always appear under (any-hover: none). |
| Motion | Each animation has a reason from Motion. Test with prefers-reduced-motion: reduce emulated in Chromium. |
| Text | Markup contains no hard-coded English. Strings follow UI text. |
| Icons | Decorative icons are hidden from assistive technology. Status uses color, shape and text. See Icons and pictograms. |
| Async | Throttle the network in DevTools and test first load, refresh, slow response, failure and a superseded request. Nothing moves when an indicator appears. See Async states. |
| Timing | New delays live in src/constants/timing.js. Nothing moves under the pointer while the user acts. See Timing. |
| Check | Method |
|---|---|
| Server HTML is final | A *.ssr.test.ts using renderSSR shows selection, sizes and classes in the server HTML. Derive first-render state from props and $$slots. Child registration does not run on the server. See Server rendering tests. |
| Hydration | A *.hydrate.test.ts with empty diffIgnoringIds, identity.pct of 100, empty settledDiff and no brokenRefs. See Hydration tests. |
| No shift on mount | Add a case to e2e/ssr-layout.test.ts. For components that measure and collapse content (overflow menus, fitted toolbars), record CLS with a layout-shift PerformanceObserver. Maximum 0.005. |
| Skeleton size | Add a case to e2e/skeleton-swap.test.ts. The skeleton and the component have the same height. |
| SSR smoke test | tests/ssr-smoke.ssr.test.ts passes. Add children that need a parent context to NEEDS_PARENT. |
| Stable ids | Server and client generate the same ids. Add a compound component to tests/IdScope/Families.test.svelte and FAMILIES in tests/IdScope/families.ts, with an id on the root and none on its children; the sweep server-renders and hydrates each one. tests/IdScope/IdScope.coverage.test.ts fails when a parent sets a context its useId children read but starts no scope; exempt one only with a reason. See also tests/SsrLayout/StableIds.ssr.test.ts. |
- Store dates as instants. Compute the day and time with
Intland an optional IANAtimeZone. - Store all-day ranges as day numbers from local date parts. The range then covers the same days in every time zone and across DST changes.
- Document whether
endis inclusive or exclusive. - On 23- and 25-hour days, lay out the grid by local clock time. Keep an event's elapsed duration when it moves.
- Count calls first. To show that work does not run, count the calls. Assert zero calls for equal input and one call for changed input. See Counting redundant work.
- Time in production mode. Run
bun run test:perf <file>. Svelte 5 dev mode inflates timings 5 to 10 times. - Benchmark pure functions. Add a case to
bench/and runbun run bench:ab. See Performance benchmarks. - Measure layout and frames in a browser. Build for production. Use Playwright with Chromium. Alternate base and change runs, report medians, count layouts with CDP, and repeat at 4x CPU throttling. See Measuring in a browser.
- Check for leaks. Mount and unmount in batches. Compare listener counts and heap size between batches.
Report these values in the pull request. Give the data size for each value and the size at which the target is no longer met.
| Interaction | Laptop | 4x CPU throttling |
|---|---|---|
| Key press (arrow keys, type-ahead) | < 4 ms | < 16 ms |
| Scroll and drag | 1 frame; no long tasks; no blank frames | Same |
| Open, expand, filter | < 50 ms | < 200 ms |
| Streaming append (logs, messages) | p99 frame time ≤ 16.7 ms | Report |
| Mount at the largest expected size | Report | Report |
- Virtualize unbounded lists. Render rows beyond the viewport so the browser does not show blank space during fast scrolls. Increase overscan when a large batch of rows arrives. Compute visible rows from the viewport; overscan rows are outside it.
- Keep the active item mounted. It holds focus and the tab stop. With frozen rows or columns, compute the scroll position and call
focus({ preventScroll: true }). - Iterate the rendered rows. Build per-cell maps and lookups from rendered rows only.
- Share resources. One observer per type, one timer per interval, one window listener per event type, one live region.
- Batch layout. Read sizes from
ResizeObserverentries. Do not readoffsetWidthin a loop. Group reads and writes withcreateFrameJob. - Defer work. Run O(n) work only while the component is open or hovered. Build hidden content when it first opens, then keep it.
- Lazy-load only what an interaction opens. A child that renders only after the user opens it, such as TagSet's "View all" modal, can load with a dynamic
import()in the browser. Markup that a prop shows must be in the server HTML, so split it into its own component instead. A failed load (offline, or after a deploy) leaves the part closed and tries again on the next open. - Update incrementally. After an edit to a large document, reprocess the changed part. Reprocess the whole document when input pauses. Record undo entries at the start of each typing burst.
- Use plain markup per item when a child component would render once per item in an unbounded loop. See Per-item children.
- Use
SetandMapfor membership. Iterate ids in{#each}. Compare values in$:guards; Svelte treats new objects as changed. Batch child registration. See Batching child registration. - Cache
Intlobjects. The firstIntl.Segmenteron a page takes about 12 ms to create. - Avoid live
Rangeobjects and page-wideMutationObservers. RegisterStaticRanges with the CSS Custom Highlight API.
- Open the pull request as a draft, titled
feat(<scope>): add <Component>. - Start the description with a usage example. Then list Findings: what the work showed, with measurements where they exist.
- Add a screenshot table: White and Gray 100, then right to left and forced colors. Add 320 px if the layout changes.
- For a design change with several parts, use one commit per part and post one comment per part: the rule it applies, quoted with its section, and before and after crops at 2x of the same region.
- List deferred work and the reasons.
- Follow the New component checklist and Example conventions. Use
StackandBoxfor layout in examples.