Code

Components for displaying inline code snippets and code blocks with syntax highlighting and color variants.

Import
import { Code, Pre } from "@sugarcoat/ui-nxt";
Usage
<Code>const x = 42;</Code>
<Pre>
function hello() {
  console.log("Hello!");
}
</Pre>

Inline Code#

Use the Code component for inline code snippets within text.

Inline Code

Code Colors#

Apply different color schemes to inline code.

Default
Primary
Accent
Success
Warning
Error
Transparent

All Colors Together#

Color Comparison

Code Block (Pre)#

Use the Pre component for multi-line code blocks.

Code Block

In Context#

Using code components within documentation-style content.

Documentation Style

Semantic Usage#

Use different colors to convey meaning in documentation.

Semantic Colors

Props#

Code#

PropTypeDefaultDescription
color"default" | "primary" | "accent" | "success" | "warning" | "error" | "transparent""default"Color scheme for the code
childrenReactNode-Code content to display

Pre#

PropTypeDefaultDescription
childrenReactNode-Code block content

Styling Details#

ComponentFontBackgroundBorder Radius
CodeMonospaceSubtle backgroundSmall
PreMonospaceSubtle backgroundMedium
Customize Theme
Build your own sugarcoat/ui theme
PresetLime / Violet / Slate
Brand ColorLime
Accent ColorViolet
Gray ScaleSlate
Border RadiusLg