Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Text

  • Text
  • Heading
  • SectionHeader
  • Prose
  • Markdown
  • Formula
  • AuroraText
  • LineShadowText
  • AnimatedShinyText
  • AnimatedGradientText
  • WordRotate
  • TypingAnimation
  • SparklesText
  • SplitText
  • BlurText
  • FlipText
  • TextReveal
  • DecryptedText
  • GlitchText
  • CircularText
  • ScrollReveal
  • TrueFocus
  • ASCIIText
  • CurvedLoop
  • FallingText
  • FuzzyText
  • ScrambledText
  • ScrollFloat
  • ScrollVelocity
  • Shuffle
  • TextCursor
  • TextPressure
  • VariableProximity

Code

  • Code
  • CodeBlock
  • Snippet
  • CodeDiff
  • Kbd

Code

code

Styles short inline code fragments with a token-aware monospace surface.

Usage

Inline code

The short code token wrapped in the text flows as a whole.

Run pnpm install Install dependencies
tsx
<span className="text-sm text-foreground">
  Run <Code>pnpm install</Code> to install dependencies
</span>

Shade Variants

tone uses semantics token: default / primary / danger.

const x = 1--filter=wwwrm -rf
tsx
<>
  <Code>const x = 1</Code>
  <Code tone="primary">--filter=www</Code>
  <Code tone="danger">rm -rf</Code>
</>

When to use

Use Code for inline commands, identifiers, or paths with monospace styling and semantic tones. It can render directly in an RSC. Use CodeBlock for multiline syntax-highlighted code, Snippet for a copyable command, or Kbd for keyboard keys.

Import

ts
import { Code, codeVariants } from "@hulianui/ui"

Props

NameTypeDefaultDescription
tone"default" | "primary" | "danger""default"Color tone: Default/Main color (emphasis)/Danger (destructive command)

All remaining native <code> (HTMLElement) attributes are supported. codeVariants is a CVA function for reusing the same styles on custom elements.

Slots

SlotTypeDescription
childrenReactNodeCode content

Usage guidelines

  • Very long content wraps inside the chip. It breaks mid-token only when the whole token cannot fit on one line (overflow-wrap: anywhere), and each fragment keeps its own rounded corners and padding (box-decoration-break: clone), so narrow containers (phones, sidebars, table cells) are no longer pushed wider. Use CodeBlock for multi-line code.

Related

CodeBlock · Snippet · CodeDiff · Kbd · Text · Heading

Playground

const x = 1
<Code>const x = 1</Code>
PreviousTrueFocusTypographyNextCodeBlock

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Slots
    • Usage guidelines
    • Related
  • Playground