Agentic UI/CodeBlock

CodeBlock

AI가 생성한 코드를 표시하는 블록 컴포넌트입니다. 복사 버튼, 라인 번호, 파일명 표시를 지원합니다.

Installation

bash
npx @axis-ds/cli add code-block --agentic

Usage

tsx
import { CodeBlock } from '@axis-ds/agentic-ui'

export function Example() {
  return (
    <CodeBlock
      code={`function hello() {
  console.log('Hello, World!')
}`}
      language="typescript"
      filename="hello.ts"
      showLineNumbers
    />
  )
}

Interactive Demo

use-user.tstypescript

Variants

파일명 + 라인 번호

example.js

언어만 표시

sql
SELECT * FROM users
WHERE active = true
ORDER BY created_at DESC

최대 높이 제한

scrollable.ts

Props

codeRequired
Type:string

표시할 코드 문자열

language
Type:string
Default:-

언어 힌트 (표시용)

filename
Type:string
Default:-

파일 이름

showLineNumbers
Type:boolean
Default:false

라인 번호 표시 여부

onCopy
Type:(code: string) => void
Default:-

복사 콜백

maxHeight
Type:string
Default:-

최대 높이 (CSS 값)

className
Type:string
Default:-

추가 CSS 클래스

Accessibility

복사 버튼에 aria-label이 제공되고, 장식 요소는 role="presentation" / aria-hidden 처리됩니다.

KeyAction
Tab복사 버튼으로 이동합니다.
Enter / Space코드를 클립보드에 복사합니다.
  • 코드는 pre/code 구조로 보존되어 스크린리더가 인식합니다.