Skip to content

components/CodeFrame

import { … } from 'zidane-ui'ui/src/components/CodeFrame.tsx

CodeFrame with caption
agent.ts
const agent = createAgent({ ...basic, provider })
await agent.run({ prompt: 'build a REST API' })
CodeFrame plain (copy on hover), long line
cat packages/server/src/handlers/very-long-folder-name/another-nested-directory/session-title-generator.ts | head -n 200 # a long line scrolls inside the frame
CodePanel
$ bun test
41 passed
CopyButton inline, Keycaps
Command KCommand Shift Returnesc

Components#

CodeFrameComponent#

Renders code in its surface with a copy button revealed on hover. Without caption it is the bare code panel; with caption it adds a tray with a header. The ref goes to the outer element.

TypeScript
const CodeFrame: ForwardRefExoticComponent<CodeFrameProps & RefAttributes<HTMLDivElement>>
CodeFrame props
NameTypeDescription
actions?(buttonClass: string) => ReactNode

Extra controls before Wrap and Copy (a diagram's source toggle). Receives the class the frame's own buttons wear (revealed on hover, sized and backed for this form): put it on each control.

caption?ReactNode

Header content. When set, the code sits in a tray under a header with the icon, this caption and the copy button, and a string caption also names the scroll group. Omit it for the bare code panel.

childrenReactNode

The code to show, such as highlighted HTML or a <pre>, with no background of its own: the frame is its surface.

className?string

Extra classes on the outer element.

codestring

The plain text the copy button writes.

copyLabel?string

Accessible name of the copy button. Defaults to the copyCode label from useLabels.

icon?string

Icon class before the caption.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

wrap?boolean

Start with long lines wrapped. Defaults to the CodeWrapProvider value (off without one).

ui/src/components/CodeFrame.tsx:152

CodeWrapProviderComponent#

Sets whether code frames below start with long lines wrapped (each frame's toggle still flips its own).

TypeScript
function CodeWrapProvider(props: CodeWrapProviderProps): Element
Parameters
NameTypeDescription
propsCodeWrapProviderProps

wrap: the default; children: the subtree it applies to.

Element
CodeWrapProvider props
NameTypeDescription
childrenReactNode

The subtree it applies to.

wrapboolean

Whether frames start wrapped.

ui/src/components/CodeFrame.tsx:61

Interfaces#

CodeFramePropsInterface#

Props of CodeFrame.

TypeScript
interface CodeFrameProps
CodeFrameProps properties
NameTypeDescription
actions?(buttonClass: string) => ReactNode

Extra controls before Wrap and Copy (a diagram's source toggle). Receives the class the frame's own buttons wear (revealed on hover, sized and backed for this form): put it on each control.

caption?ReactNode

Header content. When set, the code sits in a tray under a header with the icon, this caption and the copy button, and a string caption also names the scroll group. Omit it for the bare code panel.

childrenReactNode

The code to show, such as highlighted HTML or a <pre>, with no background of its own: the frame is its surface.

className?string

Extra classes on the outer element.

codestring

The plain text the copy button writes.

copyLabel?string

Accessible name of the copy button. Defaults to the copyCode label from useLabels.

icon?string

Icon class before the caption.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

wrap?boolean

Start with long lines wrapped. Defaults to the CodeWrapProvider value (off without one).

ui/src/components/CodeFrame.tsx:66

CodeWrapProviderPropsInterface#

Props for CodeWrapProvider.

TypeScript
interface CodeWrapProviderProps
CodeWrapProviderProps properties
NameTypeDescription
childrenReactNode

The subtree it applies to.

wrapboolean

Whether frames start wrapped.

ui/src/components/CodeFrame.tsx:49