Skip to content

Secret reveal

A freshly generated secret shown exactly once: monospace value, copy, one-time hint, optional regenerate.

View as Markdown

Preview

Device token

Device token

nxd_9f3c2a7e5b1d4c6a8e0f2b7d

Only visible now. Only its hash is stored.

<section class="nx-secret" aria-labelledby="nxsecret-_R_0_">
  <p id="nxsecret-_R_0_" class="nx-secret__label">Device token</p>
  <div class="nx-secret__row">
    <code class="nx-secret__value" translate="no"
        spellCheck="false">nxd_9f3c2a7e5b1d4c6a8e0f2b7d</code>
    <button type="button"
        class="nx-btn nx-btn--outline nx-btn--sm nx-secret__copy">
      <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14"
          viewBox="0 0 24 24" fill="none" stroke="currentColor"
          stroke-width="2" stroke-linecap="round"
          stroke-linejoin="round" class="lucide lucide-copy"
          aria-hidden="true" focusable="false">
        <rect width="14" height="14" x="8" y="8" rx="2"
            ry="2"></rect>
        <path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9
            2 2"></path>
      </svg>
      <span>Copy</span>
    </button>
  </div>
  <p class="nx-secret__feedback" role="status"
      aria-live="polite"></p>
  <p class="nx-secret__hint">Only visible now. Only its hash is
      stored.</p>
  <div class="nx-secret__actions">
    <button type="button" class="nx-btn nx-btn--ghost nx-btn--sm">
      <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14"
          viewBox="0 0 24 24" fill="none" stroke="currentColor"
          stroke-width="2" stroke-linecap="round"
          stroke-linejoin="round" class="lucide lucide-refresh-cw"
          aria-hidden="true" focusable="false">
        <path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21
            8"></path>
        <path d="M21 3v5h-5"></path>
        <path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3
            16"></path>
        <path d="M8 16H3v5"></path>
      </svg>
      <span>Regenerate</span>
    </button>
    <button type="button"
        class="nx-btn nx-btn--primary nx-btn--sm">Done</button>
  </div>
</section>

API

React props (NxKit)

React (NxKit) props
PropTypeDefaultRequiredDescription
valuestringRequiredThe secret. Rendered once as text, never in an attribute.
labelstringRequiredVisible label, e.g. "Device token".
hintReactNodeRequired"Only visible now, only the hash is stored" in the app's language.
copyLabelstringRequiredCopy button text.
copiedLabelstringRequiredAnnounced after a successful copy.
copyFallbackLabelstringRequiredAnnounced when the clipboard is unavailable and the value was selected instead.
onCopy() => voidundefinedCalled after a successful clipboard write.
regenerateLabelstringundefinedWith onRegenerate: shows the regenerate action.
onRegenerate() => voidundefinedRegenerate handler.
closeLabelstringundefinedWith onClose: shows the close action; afterwards the value is gone from the DOM.
onClose() => voidundefinedClose handler.
classNamestringundefinedLayout class.

Classes

Framework-agnostic classes
ClassDescription
.nx-secretStack
.nx-secret__valueMonospace value on surface-2, hairline, wraps anywhere, user-select: all
.nx-secret__feedbackrole=status live region for copy feedback
.nx-secret__hintOne-time hint
.nx-secret__actionsRegenerate / close

Accessibility

  • The copy result is announced through a status region that is mounted empty. Without a clipboard the value is selected, so Ctrl+C or the context menu works.
  • The value is plain text (translate=no) and leaves the DOM when the reveal is closed or unmounted; it is never placed in a title, value or data attribute.

Do / Don’t

  • Do: Show it once right after generating, then store only the hash.Don't render the secret again on a later visit, or keep it in an input's value.

View in spec