Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

API Key Chip Developer Portal Navbar Block for React

A developer-portal bar with a masked API key chip: a Reveal toggle that shows the key for ten seconds and puts the mask back by itself, and a copy button, between the docs links and a Get a key button.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A masked API key for React with Base UI, in the bar of an API platform called Keystack. One bar between the page's rails, cut into cells by solid dividers that meet the top rule: the wordmark, Docs, API reference, SDKs and Status (from xl), the key cell, then Dashboard and one Shine Button. The key cell holds a "Live" badge and the key in monospace, masked to its first eight and last four characters. A Reveal toggle shows the whole key and puts the mask back by itself after ten seconds, saying so in a polite line, or at once when you press it again; the copy button copies the whole key either way and says "API key copied". The key sits over an unseen copy of both forms, so the bar never changes width. On a phone a menu button opens a sheet from the top with the links, the same chip and the actions. It's built from Toggle, Copy Button, Badge, Sheet, Guides, Shine Button and Button, with your theme's tokens for every colour. For developer sites where the key should be one click away and never left on screen. The key is made up.

FAQ

How do I use my own key, and what does Copy copy?

Set KEY at the top of the file; the mask (MASKED) and the "ending in" text are derived from it. In an app, pass the key from your session instead. Copy always puts the whole key on the clipboard, masked or not, because the mask only changes what is drawn; the button's label says "Copy API key" and the result is announced. The key here is invented and does nothing.

How does the ten-second re-mask work?

Pressing Reveal sets the key as shown and starts one timer of SHOWN_MS (ten seconds); when it ends, the mask returns and a polite line says "Key hidden." Pressing the toggle again hides it at once and cancels the timer. There is no countdown to read and nothing else in the bar moves; change SHOWN_MS for another delay. The timer is a security measure, so it is not extended by hovering or focus.

How does it work with a keyboard and a screen reader?

The links sit in a nav named Main with the current page marked. The toggle is a button named "Reveal key" that reports whether it is pressed; while the key is masked it is read as "API key ending in 4f2a" (the dots are drawing), and when shown the key is read out as text. The announcements ("Key shown for 10 seconds.", "Key hidden.") come from a polite status that is present from load. The copy button reports success or failure through its own live text.

How does it work on a phone?

Below the xl breakpoint a menu button opens a sheet from the top with the links, the key chip (the key on its own line, the toggle and copy beneath it) and Dashboard; the chip leaves the bar below lg. The bar keeps the wordmark's icon and "Get a key"; nothing wraps at 320 pixels. Revealing inside the sheet works the same and the timer keeps running if you close it. Escape closes the sheet and focus goes back to the menu button.

Does it work right to left?

Yes. The bar mirrors and the dividers stay between the cells. The key and the wordmark always read left to right, as code and artwork do. Wrap the block in your direction provider (the catalog's DirectionProvider) so the sheet follows the page.

What moves, and what happens with reduced motion?

The copy button's icon swaps for a check and the sheet slides down; revealing and re-masking are instant swaps, not animations. With reduced motion the sheet appears without sliding and nothing else changes.

  • Pro

    Live Request Rate Navbar

    Meters and progress

    A developer navbar for a payments API: a requests-per-second counter, an error rate taken from four endpoints, and a table of their health.

  • Pro

    A documentation bar with a version menu (v4 Latest, v3 and v2 flagged as older) that rewrites a path preview, and an On this page popover of five heading links.

  • Pro

    A one-bar navbar for an open source embedded database: a version badge by the wordmark, Docs, Examples and Playground links, a Releases menu of the last three versions, a GitHub stars button with a typed count and a Get started Shine Button.

  • Pro

    Environment Switcher Navbar

    Accounts and scopes

    An app bar with a Production, Staging and Development segment control that shows the environment's base URL with a copy button and asks for confirmation before switching to Production.

  • Pro

    A navbar for a support-desk product with a search field whose popup lists help articles and categories in two labelled groups, marks the matching letters, and offers an Ask support link when nothing matches.

  • Pro

    A one-bar marketing navbar for a product roadmap tool: a wordmark, a Product menu of four areas with icons and one-line descriptions, plain links with the current page marked, Sign in and a Shine Button, and a sheet with the same links on phones.