Code
Show a short inline code fragment.
Overview
Code marks a short literal fragment in a sentence, such as a command, file name, key, or value.
Use when
You need an inline command, file name, token, or other short literal value.
Use instead
Use CodeBlock for multi-line source, commands, or code that readers may copy.
Usage
Run bun run typecheck before committing.
import { Code, Text } from "@smoothie-framework/whisk-react";
<Text>Run <Code>bun run typecheck</Code> before committing.</Text>Examples
Sizes
Use size to match inline code to the surrounding type scale.
console.log()
console.log()
console.log()
console.log()
import { Code, Stack, Text } from "@smoothie-framework/whisk-react";
<Stack gap={2}>
<Text>
<Code size="xs">console.log()</Code>
</Text>
<Text>
<Code size="sm">console.log()</Code>
</Text>
<Text>
<Code size="md">console.log()</Code>
</Text>
<Text>
<Code size="lg">console.log()</Code>
</Text>
</Stack>Variants
Use variant to choose the visual treatment for inline code.
solid
subtle
outline
surface
plain
import { Code, Stack, Text } from "@smoothie-framework/whisk-react";
<Stack gap={2}>
<Text>
<Code variant="solid">solid</Code>
</Text>
<Text>
<Code variant="subtle">subtle</Code>
</Text>
<Text>
<Code variant="outline">outline</Code>
</Text>
<Text>
<Code variant="surface">surface</Code>
</Text>
<Text>
<Code variant="plain">plain</Code>
</Text>
</Stack>Colors
Use a semantic color only when the surrounding text also explains the fragment's meaning.
default
info
success
warning
error
import { Code, Stack, Text } from "@smoothie-framework/whisk-react";
<Stack gap={2}>
<Text>
<Code color="default">default</Code>
</Text>
<Text>
<Code color="info">info</Code>
</Text>
<Text>
<Code color="success">success</Code>
</Text>
<Text>
<Code color="warning">warning</Code>
</Text>
<Text>
<Code color="error">error</Code>
</Text>
</Stack>Shortcut
Choose the kbd host when the literal describes keys someone presses, rather than source code or a command. Show the keys for the person's platform.
Press Ctrl K / ⌘K to open search.
import { Code, Text } from "@smoothie-framework/whisk-react";
<Text>
Press <Code as="kbd">Ctrl K</Code> / <Code as="kbd">⌘K</Code> to open search.
</Text>Output
Choose the samp host for output produced by a program or device. It retains the same compact visual treatment.
The command returns Build completed.
import { Code, Text } from "@smoothie-framework/whisk-react";
<Text>
The command returns <Code as="samp">Build completed</Code>.
</Text>Props
Component props
Shared props
Accessibility
Code renders a native code element by default. Use as="kbd" for keyboard input and as="samp" for sample output when those meanings apply. Do not depend on color alone, and keep short literals readable at browser zoom. Code escapes text content and does not execute or syntax-highlight it. Use CodeBlock for multi-line source, copied commands, or code that needs a language label.