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

Snippet

snippet

Presents a compact command or code snippet with one-click copying.

Usage

Basic usage

Single-line copyable command, with $ prompt and copy button on the right by default.

$pnpm add @hulianui/ui
tsx
<Snippet>pnpm add @hulianui/ui</Snippet>

No prompt (code snippet)

symbol={null} removes the prompt and colors according to JS rules, suitable for pasting code snippets.

const theme = useTheme()
tsx
<Snippet symbol={null}>const theme = useTheme()</Snippet>

Custom copy text

text Specifies the actual copy content, which can be different from the display text.

$pnpm --filter ... build
tsx
<Snippet text="pnpm --filter @hulianui/ui build">
  pnpm --filter ... build
</Snippet>

A set of getting-started steps (SnippetGroup)

SnippetGroup stacks several commands in one card and draws the frame and separators; muted marks a secondary row; overlay holds a decorative layer such as BorderBeam.

$pnpm add @hulianui/ui @hulianui/tokens
$npx @hulianui/mcp init-agent
https://hulian.dev/start
tsx
<SnippetGroup overlay={<BorderBeam size={120} duration={9} />}>
  <Snippet>pnpm add @hulianui/ui @hulianui/tokens</Snippet>
  <Snippet>npx @hulianui/mcp init-agent</Snippet>
  <Snippet symbol={null} highlight={false} muted>https://hulian.dev/start</Snippet>
</SnippetGroup>

When to use

Use Snippet for a single-line command or code fragment with an optional prompt and one-click copy, such as an install command or CLI instruction. Use CodeBlock for multiline code, or Code for inline code without copy behavior.

Import

ts
import { Snippet, SnippetGroup } from "@hulianui/ui"

Props

NameTypeDefaultDescription
textstring-Clipboard text; defaults to children when it is a string.
symbolstring | null"$" (outline), null (plain)Command prompt; pass null for non-command fragments or inline fields.
langstring-Syntax coloring language (such as "tsx"/"bash"), only takes effect when children is a string
highlightbooleantrue (outline), false (plain without lang)Whether to use syntax coloring, only takes effect when children is a string
size"sm" | "md""md"Size; sm fits compact table cells and Descriptions items.
variant"outline" | "plain""outline"Visual variant; outline renders a bordered box, plain renders borderless inline copyable text with no prompt or syntax highlight by default.
copyLabelstringLocale valueCopy-button accessible label; an explicit value takes precedence.
copiedLabelstringLocale valuePost-copy accessible label; an explicit value takes precedence.
mutedbooleanfalseA secondary row: a slightly sunken background and secondary-gray text (an alternative command, a link meant for an AI assistant).
classNamestring-Container class name

Events

EventTypeDescription
onCopy(text: string) => voidCalled after clipboard write succeeds, receiving the copied text (useful for showing a toast).

SnippetGroup (several copyable commands stacked in one card; the group draws the frame and row separators, and each Snippet inside drops its own border and background and spans the row)

NameTypeDefaultDescription
overlayReactNode-An absolutely positioned decorative layer (BorderBeam and similar), drawn outside the separated list so it doesn't count as a row.

Slots

SlotTypeDescription
childrenReactNodeDisplay content (string or node)

Example

tsx
<Snippet>pnpm add @hulianui/ui</Snippet>

// Non-command fragment without a prompt
<Snippet symbol={null}>const theme = useTheme()</Snippet>

// Compact inline copyable field inside tables or Descriptions
<Snippet variant="plain" size="sm" onCopy={(v) => toast({ title: `Copied ${v}` })}>
  ORD-20261202-001
</Snippet>

// A set of getting-started steps stacked in one card; the last row is secondary
<SnippetGroup overlay={<BorderBeam size={120} />}>
  <Snippet>pnpm add @hulianui/ui @hulianui/tokens</Snippet>
  <Snippet>npx @hulianui/mcp init-agent</Snippet>
  <Snippet symbol={null} highlight={false} muted>https://hulian.dev/start</Snippet>
</SnippetGroup>

Usage guidelines

  • Syntax highlighting through lang/highlight and automatic clipboard text apply only when children is a string. For a React node, provide text explicitly for copying.
  • Default copy labels follow ConfigProvider locale; enUS provides “Copy / Copied”, and the no-provider fallback remains Chinese.
  • The snippet never grows wider than its parent: a long run without spaces (a URL, a token) wraps at any point when it does not fit. Up to 0.74.1 it did not wrap and pushed the snippet and its parent past the viewport.
  • Copying uses navigator.clipboard.writeText first and falls back to an off-screen textarea with document.execCommand("copy") in non-HTTPS environments; the checkmark state and onCopy only fire when the copy succeeds.

Related

Code · CodeBlock · CodeDiff · Kbd · Text · Heading

PreviousCodeBlockTypographyNextCodeDiff

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Slots
    • Example
    • Usage guidelines
    • Related