Skip to content
v0.2.10

CodeSnippet

Selectable, wrapping code with an optional host-owned action.

Preview
npx @flood-md/[email protected] init

Use CodeSnippet

CodeSnippet is a named export of @flood-md/react. Connect the package once, then import what you use.

First time here? Connect Flood
Example import style
code-snippet.tsxTSX
"use client";

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

export function Example() {
  return (
    <FloodRoot>
      <CodeSnippet code="git status --short" />
    </FloodRoot>
  );
}

Design notes

  • CodeSnippet escapes code content and uses the semantic system monospace font stack.
  • The host implements copy behavior, failure handling and feedback. No clipboard or network API runs inside the component.
  • Code text defaults to LTR independently of parent layout. codeDirection can be ltr/rtl/auto; native dir still controls the wrapper and action layout.

API reference

PropValuesDefault
codestringRequired
codeDirection"ltr" | "rtl" | "auto""ltr"
actionReactNode—
Native HTML propsOmit<HTMLAttributes<HTMLDivElement>, "children">Forwarded
View TypeScript source