본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

@atlaskit/code — 코드

원문 보기 위키 갱신

본문 텍스트와 함께 짧은 코드 조각을 표시할 때 사용하는 컴포넌트예요. 인라인 코드와 다중 줄 코드 블록을 제공해요.

출처: 문서

본문

Code component

본문 텍스트와 함께 있는 짧은 코드 조각에 사용해요.

  • 키워드: code, snippet, inline, syntax, programming
  • 카테고리: data-display
  • 상태: general-availability

예시

import Code from '@atlaskit/code/code';
const _default_1: React.JSX.Element[] = [<Code>{`<Code />`}</Code>];
export default _default_1;

Props

Prop Type Description
children string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal Content to be rendered in the inline code block
codeBidiWarningLabel string Label for the bidi warning tooltip
hasBidiWarnings boolean When set to false, disables code decorating with bidi warnings
isBidiWarningTooltipEnabled boolean Sets whether to render tooltip with the warning or not

사용 지침

  • 본문 텍스트와 함께 있는 짧은 인라인 코드 조각에 사용해요
  • 기본 스타일은 재정의할 수 있어요
  • 코드 블록과 인라인 코드를 구분해 고려해요

콘텐츠 지침

  • 명확하고 읽기 쉬운 코드 예시를 사용해요
  • 코드 조각을 간결하게 유지해요
  • 예시에서 의미 있는 변수 이름을 사용해요

접근성 지침

  • 스타일을 재정의할 때 텍스트 가독성을 위해 대비율이 4.5:1 이상이 되도록 해요
  • 코드 콘텐츠가 스크린 리더에 올바르게 안내되도록 해요
  • 코드 맥락과 의미를 고려해요

CodeBlock component

구문 강조와 함께 다중 줄 코드 블록을 표시하는 컴포넌트예요.

  • 키워드: code, block, syntax, highlighting, multiline
  • 카테고리: data-display
  • 상태: general-availability

예시

import CodeBlock from '@atlaskit/code/code-block';
const exampleCodeBlock = `export default ({ name }: { name: string }) => <div>Hello {name}</div>;`;
const _default_1: React.JSX.Element[] = [
	<CodeBlock highlight="15" language="tsx" text={exampleCodeBlock} />,
];
export default _default_1;

Props

Prop Type Description
codeBidiWarningLabel string Label for the bidi warning tooltip
firstLineNumber number Sets the number of the first line, if showLineNumbers is set to true
hasBidiWarnings boolean When set to false, disables code decorating with bidi warnings
highlight string Comma delimited lines to highlight
highlightedEndText string Screen reader text for the end of a highlighted line
highlightedStartText string Screen reader text for the start of a highlighted line
isBidiWarningTooltipEnabled boolean Sets whether to render tooltip with the warning or not
label string Text used to describe that the content of the code block is scrollable
language "html" | "ruby" | "text" | "as" | "css" | "plaintext" | "d" | "r" | "PHP" | "php" | "php3" | "php4" | "php5" | "Java" | "java" | "CSharp" | "csharp" | "c#" | "Python" | "python" | "py" | ... 232 more ... | "markdown" Language reference designed to be populated from SUPPORTED_LANGUAGES in
design-system/code
shouldShowLineNumbers boolean Sets whether to display code line numbers or not
shouldWrapLongLines boolean Sets whether long lines will create a horizontally scrolling container
text string The code to be formatted (required)

사용 지침

  • 다중 줄 코드 예시에 사용해요
  • 구문 강조를 위해 적절한 언어를 지정해요
  • 코드 블록의 크기와 스크롤을 고려해요
  • 서식이 필요한 코드 조각에 사용해요

콘텐츠 지침

  • 명확하고 읽기 쉬운 코드 예시를 사용해요
  • 코드 서식과 들여쓰기를 고려해요
  • 예시에서 의미 있는 변수 이름을 사용해요
  • 코드 블록을 집중되고 관련성 있게 유지해요

접근성 지침

  • 코드 블록이 스크린 리더에 올바르게 안내되도록 해요
  • 코드 가독성을 위해 적절한 대비를 사용해요
  • 코드 맥락과 의미를 고려해요
  • 적절한 언어 식별을 제공해요

더 알아보기 (Learn more)