Code
Syntax highlighted code blocks
The Code component displays syntax highlighted code with copy functionality.
Usage
Use fenced code blocks in your MDX:
Renders as:
With filename
Add a filename to show a header:
Supported languages
fromsrc supports all languages via Shiki:
- JavaScript, TypeScript
- Python, Ruby, Go, Rust
- HTML, CSS, JSON, YAML
- Bash, SQL, GraphQL
- And many more
Props
| prop | type | description |
|---|---|---|
| language | string | Syntax highlighting language |
| filename | string | Optional filename header |
| highlight | string | Lines to highlight (e.g. "1,3-5") |
Behavior
- Copy button with status feedback
- Word wrap toggle
- Wrap preference persisted across pages