Logo
  • Documentation
  • Components
  • New Component Request
GitHub
GitHub
    Treon Studio
    Discord
    Twitter

    Welcome

    Introduction
    Components
    Contributors
    Installation
    Roadmap
    Status - Beta

    Components

    Author TooltipCalendar Event CardCode BlockComponent Preview TooltipChat ComposerEmail Compose CardFile DropzoneFile PreviewGitHub Stars ButtonGoal CardHolo CardKnowledge GraphLink PreviewiOS Message BubblesModel SelectorNavbar MenuNested MenuNotification CardPricing CardRaised ButtonSearch Results TabsSlash Command DropdownTodo ItemTwitter CardWeather CardWorkflow Card

    Form Inputs

    Async Select
    Button
    Button Group
    Checkbox
    Color Picker
    Combobox
    Hierarchical Select
    Input
    Input Base
    Input O T P
    Mask Input
    Multi Select
    Number Input
    Radio Card Group
    Radio Group
    Range Slider
    Search Input
    Segmented Button
    Select
    Slider
    Switch
    Tag Input
    Textarea
    Voice Input

    Layout

    Aspect Ratio
    Card
    Card Icons
    Card Input
    Collapsible
    Divider
    Grid
    Island
    Panel
    Portal
    Resizable
    Scroll Area
    Scroll Shadow
    Separator
    Spacer
    Visually Hidden
    Visually Hidden Input

    Navigation

    Breadcrumb
    Context Menu
    Dropdown Menu
    Menu
    Navbar
    Pagination
    Sidebar
    Steps
    Tab Navigation
    Tabs

    Feedback

    Alert
    Banner
    Callout
    Circular Progress
    Empty State
    Error Message
    Error Page
    Loader Inline
    Loader Screen
    Progress
    Progress Bar
    Skeleton
    Spinner
    Status Dot
    Toast
    Toaster
    Tooltip
    Top Banner
    Tour

    Data Display

    Advanced Table
    Badge
    Badge Overflow
    Data Table
    Description List
    Listbox
    Table
    Tag
    Timeline
    Tree
    Virtualized

    Overlays

    Alert Dialog
    Dialog
    Dialog Stack
    Drawer
    Hover Card
    Popover

    Charts

    Area Chart
    Bar Chart
    Bar List
    Category Bar
    Combo Chart
    Comparison
    Conditional Bar Chart
    Contribution Graph
    Radar Chart

    Calendars

    Attendance Calendar
    Calendar
    Date Picker
    Date Time Field
    Full Calendar
    Gantt
    Mini Calendar
    Schedule
    Schedule Grid
    Time Field

    Typography

    Code
    Code Block
    Control Help
    Control Label
    Field
    Heading
    Kbd
    Label
    Link
    Markdown
    Rich Text Editor
    Snippet
    Text

    Media

    Avatar
    Avatar Group
    Deck
    Document Preview
    File List
    File Upload
    Glimpse
    Image
    Image Crop
    Image Zoom
    Photo Gallery
    Profile Picture
    Q R Code
    Q R Scanner

    User

    Discussion
    Rating
    Testimonial
    User
    User Card

    Interactive

    Accordion
    Action Bar
    Command
    Copy Button
    Cursor
    Emoji Picker
    Fade
    Inline Edit
    Kanban
    Marquee
    Orbit
    Ripple
    Sortable

    Specialized

    App Header
    Bulk Grade Input
    Credit Card
    Footer
    Level Picker
    Notification Card
    Password Strength
    Payment Method
    Pricing Table
    Sandbox
    Stat Card
    Ticker
    Usage Card
    Wizard
    DocsComponents

    Code Block

    A syntax-highlighted code block with copy and download functionality, perfect for displaying code snippets in documentation and tutorials.

    Made with ❤️ byTreon Studio.Source code available onGitHub

    On This Page

    • Usage in Gaia
    • Features
    • Installation
    • Usage
    • Examples
    • Different Languages
    • With Line Numbers
    • Props
    • Supported Languages
    • Tips
    • Integration with Syntax Highlighters
    • Custom Styling
    Website screenshot
    Meet Bungas
    Your open-source, proactive personal AI assistant with 200+ integrations. Bungas combines todos, goals, calendar, and email into one system, turns tasks into automated workflows, and completes work instead of just tracking it. Open-source and self-hostable with support for custom automations and multi-step workflows.
    example.js
    function greet(name) {
      console.log(`Hello, ${name}!`);
      return `Welcome to Bungas UI`;
    }
    
    greet("Developer");

    Usage in Gaia

    Makes AI-generated code readable and usable. Auto-detects language and adds copy-paste utility.

    Features

    • Copy to Clipboard - One-click code copying with visual feedback
    • Download - Save code snippets as files with appropriate extensions
    • Line Numbers - Optional line number display
    • Language Support - Auto-detects file extensions for 20+ languages
    • Filename Display - Show the filename in the header
    • Syntax Highlighting Ready - Works seamlessly with syntax highlighting libraries

    Installation

    npx shadcn@latest add https://bungas.treonstudio.com/r/code-block.json

    Usage

    import { CodeBlock } from "@/components/ui/code-block";
     
    export default function Example() {
      const code = `function hello() {
      console.log("Hello, World!");
    }`;
     
      return (
        <CodeBlock language="javascript" filename="hello.js">
          {code}
        </CodeBlock>
      );
    }

    Examples

    Different Languages

    fibonacci.py
    def fibonacci(n):
        if n <= 1:
            return n
        return fibonacci(n-1) + fibonacci(n-2)
    
    print(fibonacci(10))
    types.ts
    interface User {
      id: string;
      name: string;
      email: string;
    }
    
    const createUser = (data: User): User => {
      return { ...data };
    };
    deploy.sh
    #!/bin/bash
    # Deploy script
    echo "Building application..."
    npm run build
    echo "Deploying to production..."
    npm run deploy

    With Line Numbers

    component.tsx
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    import React from "react"; import { cn } from "@/lib/utils"; export function Component({ className }) { const [count, setCount] = React.useState(0); return ( <div className={cn("container", className)}> <h1>Count: {count}</h1> <button onClick={() => setCount(count + 1)}> Increment </button> </div> ); }

    Props

    PropTypeDefaultDescription
    childrenstring-The code content to display
    languagestring"plaintext"Programming language for syntax highlighting
    filenamestring-Optional filename to display in header
    showLineNumbersbooleanfalseShow line numbers on the left
    classNamestring-Additional CSS classes

    Supported Languages

    The component automatically detects file extensions for the following languages:

    • JavaScript (.js)
    • TypeScript (.ts)
    • Python (.py)
    • Java (.java)
    • C++ (.cpp)
    • C (.c)
    • C# (.cs)
    • Ruby (.rb)
    • Go (.go)
    • Rust (.rs)
    • PHP (.php)
    • Swift (.swift)
    • Kotlin (.kt)
    • HTML (.html)
    • CSS (.css)
    • JSON (.json)
    • XML (.xml)
    • YAML (.yaml)
    • Markdown (.md)
    • Bash/Shell (.sh)
    • SQL (.sql)

    Tips

    Integration with Syntax Highlighters

    This component works great with syntax highlighting libraries like react-syntax-highlighter or prism-react-renderer. Simply wrap the code content with your preferred highlighter:

    import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
    import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism';
     
    <CodeBlock language="javascript">
      <SyntaxHighlighter language="javascript" style={oneDark}>
        {code}
      </SyntaxHighlighter>
    </CodeBlock>

    Custom Styling

    Override the default styles using Tailwind classes:

    <CodeBlock 
      className="border-blue-500 bg-blue-950" 
      language="python"
    >
      {code}
    </CodeBlock>