Skip to content

Components

CodeBlock

results.tsTypeScript
const results = [
  { id: 1, title: 'Review the accessibility and keyboard navigation results' },
  { id: 2, title: 'Confirm the narrow layout' },
];

export const total = results.length;
export default results;

Component reference

Properties

Use CodeBlock

Display and copy multiline source in a bounded, keyboard-scrollable surface.

Example import style
code-block.tsxTSX
"use client";

import { FloodRoot, CodeBlock } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <CodeBlock filename="example.ts" language="TypeScript" code={"export const limit = 10;\nexport const page = 1;"} />
    </FloodRoot>
  );
}

Design notes

  • Pass original source text. Indentation and line breaks are preserved when copying.
  • Use wrap when reading across a narrow surface matters more than retaining visual line width.
  • Use CodeSnippet for a short command or inline installation snippet. The CodeBlock language is a label.

API reference

PropValuesDefault
codestringRequired
labelstring"Code example"
filenamestring—
languagestring—
maxBlockSizestring"20rem"
wrapbooleanfalse
showCopybooleantrue
copyLabelstring"Copy code"
Native HTML propsOmit<HTMLAttributes<HTMLElement>, "children" | "aria-label">Forwarded
View TypeScript source