---
title: Code
description: "`Code` is a component that represents a code block. By default, it renders a `code` element."
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
---
# Code
`Code` is a component that represents a code block. By default, it renders a `code` element.
```tsx
console.log("Hello, Yamada!")
```
## Usage
```tsx
import { Code } from "@yamada-ui/react"
```
```tsx
import { Code } from "@/components/ui"
```
```tsx
import { Code } from "@workspaces/ui"
```
```tsx
```
:::tip
To display keyboard keys or shortcuts, use [Kbd](https://yamada-ui.com/docs/components/kbd.md).
:::
### Change Variant
```tsx
{(variant, index) => (
console.log("Hello, Yamada!")
)}
```
### Change Size
```tsx
{(size, index) => (
console.log("Hello, Yamada!")
)}
```
### Change Color Scheme
```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. |
## Similar Components
- [Blockquote](https://yamada-ui.com/docs/components/blockquote.md): `Blockquote` is a component that represents a quotation. By default, it renders a `blockquote` element.
- [Em](https://yamada-ui.com/docs/components/em.md): `Em` is a component that represents emphasized text. By default, it renders a `em` element.
- [Heading](https://yamada-ui.com/docs/components/heading.md): `Heading` is a component that represents section headings. By default, it renders an `h1` element.
- [Highlight](https://yamada-ui.com/docs/components/highlight.md): `Highlight` is a component that highlights specified strings within text. By default, it renders a `p` element.
- [Kbd](https://yamada-ui.com/docs/components/kbd.md): `Kbd` is a component that represents keyboard input.
- [Mark](https://yamada-ui.com/docs/components/mark.md): `Mark` is a component that emphasizes a specific part of the text.
- [Prose](https://yamada-ui.com/docs/components/prose.md): `Prose` is a component that styles HTML content.
- [Text](https://yamada-ui.com/docs/components/text.md): `Text` is a component that represents a paragraph of text. By default, it renders a `p` element.