API key field

Enter and manage an API key for an AI provider; ds::provider-keys is a panel of them. Host-driven: the component never holds a key.

Form control. It takes input in a form, so it is drawn on the Every input type block, beside every other control, as it starts and with an error where it has one.

Anatomy

form|div[x-data][data-ds-api-key-field=status]   (listeners on the tag land here)
├── div  logo (slot or img) + label[for]
├── [hint] button[type=submit][hidden] value=save     the form's default button
├── [hint] div  key icon · "Saved key:" (sr) code hint · Test · confirm-button Remove (intent=remove)
├── [hint] details > summary "Replace key" > input row        open with an error
│   [no hint] input row
│     ds::input type=password reveal (revealLabel "Show key") · Test · Save (with action)
├── p#status[role=status]  agent mark + words            empty:sr-only
├── p#error
└── p#help  help + "Keys start with sk-."

Security, enforced in the view

  • A value attribute throws. The input never has a value on the page; only hint, masked by the host, is rendered.
  • autocomplete=off, spellcheck=false, autocapitalize=off, autocorrect=off; data-1p-ignore, data-lpignore, data-bwignore, data-form-type=other written as a courtesy, documented as not relied on.
  • Reveal is ds::input's (dsPassword): it shows only what is being typed and goes back to hidden on submit. The script stores and logs nothing.
  • With a hint, a hidden first submit button (intent=save) is the form's default button: measured in Chromium, Enter in the replacement field otherwise clicked Remove's confirm control, the first submit in tree order.

Status

unset (nothing), set (lock, "Saved"), checking, valid, invalid drawn with the agent marks of running, done and failed. invalid or an error sets aria-invalid. message replaces the words.

Intents

Test, Remove and Save post {intent}=test|remove|save; ds::provider-keys gives each row keys[id] and intent[id] in one form. Test dispatches test (bubbling, cancelable) first; cancelled, nothing posts.

Accessibility

Rolea labelled password field; Replace a native disclosure
Namethe label (":provider API key"); reveal "Show key" (aria-pressed)
Descriptionstatus, error, help by aria-describedby
KeyboardTab: Test, Remove (then its Cancel and confirm), Replace, the field, reveal, Save
Announcementthe status line is polite and always in the page
Focusevery control draws the system ring

Do not

  • Do not pass the key. Not as value, not as a hint that is most of it.
  • Do not turn prefix into validation. It is a hint.

From the package repo: edit this page on GitHub.

Was this page helpful?