Components

Code

Marks text to signify a short fragment of computer code.

console.log()
<Code>console.log()</Code>

API Reference

This component is based on the code element and supports common margin props.

PropTypeDefault
sizeenumNo default value
variant"solid" | "soft" | "outline" | "ghost""soft"
weightResponsive<"light" | "regular" | "medium" | "bold">No default value
colorenumNo default value
highContrastbooleanNo default value

Examples

Size

Use the size prop to control text size. This prop also provides correct line height and corrective letter spacing—as text size increases, the relative line height and letter spacing decrease.

console.log()console.log()console.log()console.log()console.log()console.log()console.log()console.log()console.log()
<Flex direction="column" gap="3" align="start">
<Code size="9">console.log()</Code>
<Code size="8">console.log()</Code>
<Code size="7">console.log()</Code>
<Code size="6">console.log()</Code>
<Code size="5">console.log()</Code>
<Code size="4">console.log()</Code>
<Code size="3">console.log()</Code>
<Code size="2">console.log()</Code>
<Code size="1">console.log()</Code>
</Flex>

Variant

Use the variant prop to control the visual style.

console.log()console.log()console.log()console.log()
<Flex direction="column" align="start" gap="2">
<Code variant="solid">console.log()</Code>
<Code variant="soft">console.log()</Code>
<Code variant="outline">console.log()</Code>
<Code variant="ghost">console.log()</Code>
</Flex>

Color

Use the color prop to assign a specific color, ignoring the global theme.

console.log()console.log()console.log()console.log()
<Flex direction="column" align="start" gap="2">
<Code color="indigo" variant="soft">
console.log()
</Code>
<Code color="crimson" variant="soft">
console.log()
</Code>
<Code color="cyan" variant="soft">
console.log()
</Code>
<Code color="orange" variant="soft">
console.log()
</Code>
</Flex>

High-contrast

Use the highContrast prop to add additional contrast.

console.log()console.log()console.log()console.log()
console.log()console.log()console.log()console.log()
<Flex gap="3">
<Flex direction="column" align="start" gap="2">
<Code variant="solid">console.log()</Code>
<Code variant="soft">console.log()</Code>
<Code variant="outline">console.log()</Code>
<Code variant="ghost">console.log()</Code>
</Flex>
<Flex direction="column" align="start" gap="2">
<Code variant="solid" highContrast>
console.log()
</Code>
<Code variant="soft" highContrast>
console.log()
</Code>
<Code variant="outline" highContrast>
console.log()
</Code>
<Code variant="ghost" highContrast>
console.log()
</Code>
</Flex>
</Flex>

Weight

Use the weight prop to set the text weight.

console.log()console.log()
<Flex direction="column" gap="2" align="start">
<Code weight="regular">console.log()</Code>
<Code weight="bold">console.log()</Code>
</Flex>
PreviousBlockquote
NextEm