• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
drewmcdonald

drewmcdonald

promptCompare

Public
Like
promptCompare
Home
Code
7
.claude
3
backend
2
docs
1
frontend
4
shared
.mcp.json
deno.json
Environment variables
2
Branches
1
Pull requests
Remixes
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
.claude
/
skills
/
ai-elements
/
references
/
snippet.md
Code
/
.claude
/
skills
/
ai-elements
/
references
/
snippet.md
Search
…
Viewing readonly version of main branch: v149
View latest version
snippet.md

Snippet

Lightweight inline code display for terminal commands and short code references.

The Snippet component provides a lightweight way to display terminal commands and short code snippets with copy functionality. Built on top of InputGroup, it's designed for brief code references in text.

See scripts/snippet.tsx for this example.

Installation

npx ai-elements@latest add snippet

Features

  • Composable architecture with InputGroup
  • Optional prefix text (e.g., $ for terminal commands)
  • Built-in copy button
  • Compact design for chat/markdown

Examples

Without Prefix

See scripts/snippet-plain.tsx for this example.

Props

<Snippet />

PropTypeDefaultDescription
codestringRequiredThe code content to display.
childrenReact.ReactNode-Child elements like SnippetAddon, SnippetInput, etc.
...propsReact.ComponentProps<typeof InputGroup>-Spread to the InputGroup component.

<SnippetAddon />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof InputGroupAddon>-Spread to the InputGroupAddon component.

<SnippetText />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof InputGroupText>-Spread to the InputGroupText component.

<SnippetInput />

PropTypeDefaultDescription
...propsOmit<React.ComponentProps<typeof InputGroupInput>,-Spread to the InputGroupInput component. Value and readOnly are set automatically.

<SnippetCopyButton />

PropTypeDefaultDescription
onCopy() => void-Callback fired after a successful copy.
onError(error: Error) => void-Callback fired if copying fails.
timeoutnumber2000How long to show the copied state (ms).
childrenReact.ReactNode-Custom button content.
...propsReact.ComponentProps<typeof InputGroupButton>-Spread to the InputGroupButton component.
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.