--- title: Code description: "`Code` はコードブロックを表すコンポーネントです。デフォルトでは `code` 要素をレンダリングします。" links: - style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/code/code.style.ts - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/code - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-code--basic --- ```tsx console.log("Hello, Yamada!") ``` ## 使い方 ```tsx import { Code } from "@yamada-ui/react" ``` ```tsx import { Code } from "@/components/ui" ``` ```tsx import { Code } from "@workspaces/ui" ``` ```tsx ``` ### バリアントを変更する ```tsx {(variant, index) => ( console.log("Hello, Yamada!") )} ``` ### サイズを変更する ```tsx {(size, index) => ( console.log("Hello, Yamada!") )} ``` ### カラースキームを変更する ```tsx {(colorScheme, index) => ( console.log("Hello, Yamada!") )} ``` ## Props | Prop | Default | Type | Description | | ------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | | `size` | `"sm"` | `"lg" \| "md" \| "sm" \| "xs"` | The size of the component. | | `variant` | `"subtle"` | `"outline" \| "solid" \| "subtle" \| "surface"` | The variant of the component. |