Code Block
A code viewer with syntax highlighting, a language switcher, and a copy button.
Installation
Copy the command below and run it in your terminal.
The component depends on highlight.js. Install it if your project
doesn't have it yet:
Copy the command below and run it in your terminal.
Usage
Pass a tabs array for the multi-language
form, or code + lang for a single snippet:
The built-in palette is GitHub light in light mode and GitHub dark in dark mode. For any
other highlight.js theme, set theme="custom" and load its stylesheet — the component skips its own token colors:
Examples
From a single highlighted snippet to fully composed, multi-language blocks.
Single snippet
Multiple languages
Line numbers
Custom actions
Copy placement: overlay
Copy placement: inline
Compound API
Custom theme: stylesheet
With theme="custom" the block paints no token colors itself, so a stock highlight.js stylesheet — or your own hljs-* rules, like the One Dark / One Light ones below — takes over.
Custom theme: variables
To keep the built-in palette and only shift its hues, override the --code-block-token-* variables on a wrapper. They inherit into the block per mode.
Anatomy
CodeBlock.Root - Provides code block state and layout.
CodeBlock.Header - Renders the code block header.
CodeBlock.List - Groups code language tabs.
CodeBlock.Trigger - Selects a code language tab.
CodeBlock.Actions - Groups code block actions.
CodeBlock.Copy - Copies the active code snippet.
CodeBlock.Content - Renders a code snippet panel.
CodeBlock - Renders a high-level code block.
# Import the Pinecone library from pinecone import Pinecone # Initialize a Pinecone client with your API key pc = Pinecone(api_key="YOUR_API_KEY") # Create an index for dense vectors with integrated embedding index_name = "quickstart-py" pc.create_index_for_model( name=index_name, cloud="aws", region="us-east-1", embed={ "model": "llama-text-embed-v2", "field_map": {"text": "chunk_text"}, }, )