Velocity X Components

Content & Dashboard

Code Block with Copy Button

Styled pre/code block with a filename bar and a copy button with a real success state, no syntax highlighter bundled.

Subscription Included with the Velocity Components subscription.
bash
$ velocityx add code-block-copy

Built for react. Needs react already installed as a peer dependency. An Astro-only project needs @astrojs/react wired up first — this won't run on its own in plain Astro.

Full docs for Code Block with Copy Button →

Needs a licence key — subscribe here, then velocityx loginonce.

react v1.0.0 react
Code Block with Copy Button
supabase.ts
export function getSupabase() {
  if (!PUBLIC_SUPABASE_URL || !PUBLIC_SUPABASE_ANON_KEY) {
    return createStubClient(); // never throw — chrome must render with no env
  }
  return createClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY);
}

Props

NameTypeRequiredDefaultDescription
codestringNoDEFAULT_CODEraw code — always used for the copy action
codeNodeReactNode?Yesoptional pre-highlighted markup for display only
languagestring?No'ts'shown in the top bar
filenamestring?Yesshown in the top bar, takes precedence over language label
classNamestringNo''

File this creates

The CLI writes this path into your project, relative to its root — nothing else moves.

text
components/velocity/code-block-copy/CodeBlockCopy.jsx

Using the Code Block with Copy Button component

Install it with velocityx add code-block-copy. The CLI writes the source straight into your project — no runtime dependency, no registry lock-in, and it themes itself from the same primary-*/accent-* scale as the rest of the library.

More from Content & Dashboard.