Add syntax highlighting to your code blocks with customizable styling and features. The component
offers extensive customization options including line numbers, copy buttons, language indicators,
and custom theming to match your brand. For simpler use cases, you can also use standard Markdown
code blocks as described in Code Blocks.
You can also use backticks to highlight code blocks in Markdown files, see
Code Blocks for more information.
Import
Code
import { SyntaxHighlight } from "zudoku/ui/SyntaxHighlight";
using System;using System.Linq;public class UserService { private readonly List<User> _users = new(); public async Task<User?> GetUserAsync(int id) { await Task.Delay(100); return _users.FirstOrDefault(u => u.Id == id); }}
Rust
main.rs
use std::collections::HashMap;fn main() { let mut scores = HashMap::new(); scores.insert(String::from("Blue"), 10); scores.insert(String::from("Red"), 50); println!("Team scores: {:?}", scores);}
Ruby
todo_list.rb
class TodoList attr_reader :name, :items def initialize(name) @name = name @items = [] end def add_item(description) @items << { description: description, completed: false } endend
PHP
user.php
<?phpclass User { public function __construct( public readonly int $id, public readonly string $name, public readonly string $email ) {} public function getDisplayName(): string { return ucfirst($this->name); }}
HTML
index.html
<!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8" /> <title>Zudoku Example</title> </head> <body> <h1>Welcome to Zudoku</h1> <p>Build beautiful documentation sites with ease.</p> <p> Nunc nec ornare libero. Sed ultricies lorem vitae enim vestibulum, at posuere augue ullamcorper. </p> </body></html>
import java.util.List;import java.util.stream.Collectors;public class UserService { private List<User> users; public List<User> getActiveUsers() { return users.stream() .filter(User::isActive) .collect(Collectors.toList()); }}
Go
main.go
package mainimport "fmt"type User struct { ID int Name string Email string}func main() { user := User{ID: 1, Name: "Alice", Email: "alice@example.com"} fmt.Printf("User: %+v\n", user)}
Kotlin
user.kt
data class User(val id: Long, val name: String, val email: String)class UserRepository { private val users = mutableListOf<User>() fun addUser(user: User) { users.add(user) } fun findById(id: Long): User? = users.find { it.id == id }}