Aurora AI Snippet
aurora-dinglebear-ai/aurora-ai-snippetFreeBlock
Aurora-native snippet parity surface from AI Elements.
Install it
npx shadcn@latest add https://aurora.dinglebear.ai/r/aurora-ai-snippet.jsonSource
1"use client"23import * as React from "react"4import { Check, CodeXml, Copy } from "lucide-react"5import { Badge } from "@/registry/aurora/ui/badge"6import { Button } from "@/registry/aurora/ui/button"7import { useClipboard } from "@/registry/aurora/lib/use-clipboard"89export interface SnippetProps extends React.HTMLAttributes<HTMLPreElement> {10 code: string11 /** Short language identifier shown in the header chip (e.g. "ts", "tsx", "py"). */12 language?: string13}1415/**16 * Lightweight token highlighter that reproduces the Claude Design Snippet17 * coloring: keywords in rose, member/function calls in cyan, numbers in orange,18 * strings in success-teal, everything else in primary text. Deliberately simple19 * (no external grammar) so it stays in sync with the registry token palette.20 */21const KEYWORDS = new Set([22 "export",23 "import",24 "from",25 "default",26 "const",27 "let",28 "var",29 "function",30 "async",31 "await",32 "return",33 "if",34 "else",35 "for",36 "while",37 "new",38 "class",39 "extends",40 "typeof",41 "in",42 "of",43 "yield",44 "try",45 "catch",46 "finally",47 "throw",48 "def",49 "lambda",50 "true",51 "false",52 "null",53 "undefined",54 "None",55 "True",56 "False",57])5859const TOKEN_RE =60 /(\/\/[^\n]*|#[^\n]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)|(\b\d[\d_.]*\b)|([A-Za-z_$][\w$]*)|(\s+)|([^\s\w$])/g6162function tokenColor(word: string, prevSig: string, nextSig: string): string | undefined {63 if (KEYWORDS.has(word)) return "var(--aurora-accent-pink)"64 // member access (foo.bar) or call (bar(...)) → cyan identifier65 if (prevSig === "." || nextSig === "(") return "var(--aurora-accent-primary)"66 return undefined67}6869function highlight(code: string): React.ReactNode[] {70 const out: React.ReactNode[] = []71 let match: RegExpExecArray | null72 TOKEN_RE.lastIndex = 073 let key = 074 // Track the last non-whitespace token to resolve member-access / call coloring.75 let prevSig = ""76 // Pre-scan to know the "next significant" char for each identifier.77 const tokens: { text: string; type: number }[] = []78 while ((match = TOKEN_RE.exec(code)) !== null) {79 if (match[1]) tokens.push({ text: match[1], type: 1 })80 else if (match[2]) tokens.push({ text: match[2], type: 2 })81 else if (match[3]) tokens.push({ text: match[3], type: 3 })82 else if (match[4]) tokens.push({ text: match[4], type: 4 })83 else if (match[5]) tokens.push({ text: match[5], type: 5 })84 else tokens.push({ text: match[6] ?? "", type: 6 })85 }86// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from aurora
All 176 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Aurora AI Actionaurora-ai-action | aurora | Blocks | Free | 1 dep | |
| Aurora AI Actionsaurora-ai-actions | aurora | Blocks | Free | 1 dep | |
| Aurora AI Agentaurora-ai-agent | aurora | Blocks | Free | 1 dep | |
| Aurora AI Image Gridaurora-ai-ai-image-grid | aurora | Blocks | Free | 1 dep | |
| Aurora AI Attachmentsaurora-ai-attachments | aurora | Blocks | Free | 1 dep | |
| Aurora AI Audio Playeraurora-ai-audio-player | aurora | Blocks | Free | 1 dep | |
| Aurora AI Branchaurora-ai-branch | aurora | Blocks | Free | 1 dep | |
| Aurora AI Canvasaurora-ai-canvas | aurora | Blocks | Free | 1 dep |
