Text names and descriptions

Choose the text a reference supplies

Let components supply an input’s name and description.

Try: Change the text, then inspect the input’s name and description in your accessibility tools.

DOM references and text proxies — not computed accessibilityWaiting for setup.
Behavior & limits

The fallback creates hidden text references from data-label-text and data-description-text. Components keep those public values in sync with their visible text.

This plain-text approximation does not compute accessible names from arbitrary markup. The readout shows DOM references, not computed accessibility.

Code sample

Publish text on the hosts; select a provider during fallback setup.

<input id="tn-input" type="text" aria-labelledby="tn-label-host"
    aria-describedby="tn-description-host">
<rt-gallery-label id="tn-label-host" data-reference-target="text"
    data-label-text="Delivery preference">
  <template shadowrootmode="open" shadowrootreferencetarget="text">
    <strong id="text">Delivery preference</strong>
    <p>This extra component text is outside the selected name.</p>
  </template>
</rt-gallery-label>
<rt-gallery-description id="tn-description-host" data-reference-target="text"
    data-description-text="Tell us where the parcel should be left.">
  <template shadowrootmode="open" shadowrootreferencetarget="text">
    <p id="text">Tell us where the parcel should be left.</p>
  </template>
</rt-gallery-description>
// In the conditionally loaded setup module (package imports):
import { installReferenceTarget } from 'reference-target-fallback/core';
import { textNames } from 'reference-target-fallback/adapters/text-names';

const fallback = installReferenceTarget({
  adapters: [textNames({
    getText(host, kind) {
      return host.getAttribute(kind === 'label'
        ? 'data-label-text' : 'data-description-text');
    },
  })],
});
fallback.hydrate(document);

Functional JavaScript sizes

Functional page JavaScript

5.097 KB 2.235 KB gzip

Always loaded.

Fallback additional

21.858 KB 7.813 KB gzip

Core + selected adapters.

Fallback route total

26.955 KB 10.048 KB gzip

Always-loaded and fallback files; shared files counted once.

Native-surface route total

6.086 KB 2.773 KB gzip

Includes 0.989 KB (0.538 KB gzip) of behavioral probes requested only after the property surface is present.

Minified / gzip. 1 KB = 1,000 bytes. Demo-only syntax highlighting is excluded from the functional totals and reported separately below.

Whole-page delivery context

HTML document

15.852 KB 1 request

Generated markup, including these measurements.

Initial supporting assets

21.802 KB raw 21.179 KB local transfer · 4 requests

Styles, icon, and the highlighting scheduler; functional JS is separate above.

Initial page with fallback

64.609 KB raw 47.079 KB local transfer · 10 requests

Document + functional fallback path + initial supporting assets, with unique files counted once.

Deferred highlighting

16.700 KB raw 7.831 KB local transfer · 8 requests

Engine, theme, and this page’s grammar closure, requested after a source disclosure opens or during idle time.

“Local transfer” matches the included development server: gzip JavaScript sidecars, but uncompressed HTML, CSS, and SVG. GitHub Pages, browser caching, HTTP headers, and production compression can change transferred bytes and request scheduling. Module preloads fetch functional modules early without evaluating the app and do not add duplicate transfers.

Inspect the 6 generated JavaScript files

Selected adapters: text-names.

Gzip totals sum each compressed file. The fallback and native-probe routes are mutually exclusive. Separate CSS files, HTML, JSON, source maps, HTTP headers, and Microlighter assets are excluded. Component styles embedded in JavaScript are included. Transfer sizes depend on compression and caching. Microlighter MIT license.

Files included in this page’s totals
FileDeliveryMinifiedGzip
shared/chunks/app-M4PZ3W3X.js Page 1.698 KB 0.745 KB
shared/chunks/chunk-CLCOZ6O7.js Fallback / native probe shared 0.849 KB 0.422 KB
shared/chunks/chunk-S2QLMWTP.js Page 0.142 KB 0.138 KB
shared/chunks/detect-X6QVIAY4.js Native-surface probe 0.140 KB 0.116 KB
shared/chunks/reference-target.setup-I7SMHH5F.js Fallback additional 21.009 KB 7.391 KB
text-names/main.js Page 3.257 KB 1.352 KB

Inspect the size manifest

Implementation notes & limitations

Fallback scope

Names and descriptions come from explicit public text. The adapter does not compute accessible names from arbitrary shadow content.

Readouts describe DOM state. Check computed names, keyboard behavior and assistive technology separately.