Skip to content
AI Elements

Ai Code Block

Compound code surface for tool output and streamed files.

Import

tsx
import { AiCodeBlock } from "@cronus-ui/ui";
bash
npx cronus-ui add ai-code-block

Examples

API Reference

Generated from the component's exported types.

AiCodeBlockLabels

Skip AiCodeBlockLabels props table
PropTypeDefaultDescription
copy
string
copied
string
selectFile
string

AiCodeBlockProps

Extends HTMLAttributes<HTMLDivElement>

Skip AiCodeBlockProps props table
PropTypeDefaultDescription
defaultValue
stringUncontrolled initial value.
value
stringControlled value.
onValueChange
(value: string) => voidCalled when the value changes.
data*
AiCodeBlockData[]
labels
AiCodeBlockLabelsOverride default English strings.

AiCodeBlockHeaderProps

Extends HTMLAttributes<HTMLDivElement>

No own props — see the extended type above for available props.

AiCodeBlockFilesProps

Extends Omit<HTMLAttributes<HTMLDivElement>, "children">

Skip AiCodeBlockFilesProps props table
PropTypeDefaultDescription
children*
AiCodeBlockChildrenContents of the component.

AiCodeBlockFilenameProps

Extends HTMLAttributes<HTMLDivElement>

Skip AiCodeBlockFilenameProps props table
PropTypeDefaultDescription
value
stringControlled value.

AiCodeBlockSelectProps

Extends ComponentProps<typeof Select>

Skip AiCodeBlockSelectProps props table
PropTypeDefaultDescription
children*
AiCodeBlockChildrenContents of the component.
className
stringAdditional class names merged onto the root.

AiCodeBlockSelectItemProps

Extends ComponentProps<typeof SelectItem>

No own props — see the extended type above for available props.

AiCodeBlockCopyButtonProps

Extends ComponentProps<typeof Button>

Skip AiCodeBlockCopyButtonProps props table
PropTypeDefaultDescription
onCopy
() => void
onError
(error: Error) => void
timeout
number2000
code
stringExplicit payload. Defaults to the active file in `AiCodeBlock` data.

AiCodeBlockBodyProps

Extends Omit<HTMLAttributes<HTMLDivElement>, "children">

Skip AiCodeBlockBodyProps props table
PropTypeDefaultDescription
children*
AiCodeBlockChildrenContents of the component.

AiCodeBlockItemProps

Extends HTMLAttributes<HTMLDivElement>

Skip AiCodeBlockItemProps props table
PropTypeDefaultDescription
value*
stringControlled value.
lineNumbers
booleanfalse

AiCodeBlockContentProps

Extends HTMLAttributes<HTMLPreElement>

Skip AiCodeBlockContentProps props table
PropTypeDefaultDescription
language
BundledLanguage
children*
stringContents of the component.