import React from 'react'; import { type SyntaxHighlighterProps } from 'react-syntax-highlighter'; export type CodeBlockProps = { children: string; /** * CSS class names that can be appended to the component. */ className?: string; /** * Determines whether we render a copy button (on hover) */ copyStyle?: 'text' | 'icon'; /** * The programming language to use for syntax highlighting */ language: SyntaxHighlighterProps['language']; } & Omit, 'children'>; /** * ## Usage * * Show a block of formatted code, with syntax highlighting, in a block container. * * | Type/Use | Description | Example | * |----------|-------------|---------| * | Read-only | The snippet is displayed on its own, with no copy affordance. | Illustrating syntax inline with surrounding prose. | * | Icon copy | `copyStyle="icon"` adds an icon-only button that copies the snippet. | Dense layouts where a labeled button would crowd the block. | * | Text copy | `copyStyle="text"` adds a labeled button that copies the snippet. | Snippets the reader is expected to run, like install commands. | * * ## Interaction * * `CodeBlock` displays syntax highlighting with a theme that follows the page color scheme: * `` when set, otherwise the operating system preference. It also * includes the ability to show a copy button which, when clicked, will copy the code block to * the user's clipboard. * * ## Content & Accessibility * * ### Do's * * * Use `CodeBlock` when you want to format and display any multi-line code to the user. * * Use `CodeBlock` when a single-line code block applies to command line snippets, or other code which has complex, lengthy text. * * ### Don'ts * * * Avoid using `CodeBlock` for single-word code snippets. Instead use the `Text` component with one of the `code-*` presets. * * ## Resources * * * https://github.com/react-syntax-highlighter/react-syntax-highlighter */ export declare const CodeBlock: { ({ children, className, copyStyle, language, ...other }: CodeBlockProps): React.JSX.Element; displayName: string; };