npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ajstudioz14151/codeblocks-component

v1.1.0

Published

CLI for adding AJ STUDIOZ code blocks component with syntax highlighting, copy functionality, and toast notifications

Readme

AJ STUDIOZ Code Blocks Component CLI

A powerful CLI tool for adding beautiful code blocks with syntax highlighting, copy functionality, and toast notifications to your React/Next.js projects.

Features

Syntax Highlighting - Beautiful code syntax highlighting using sugar-high
📋 Copy to Clipboard - One-click copy with success/error toast notifications
🔄 Line Wrapping - Toggle between horizontal scroll and line wrapping
Performance Optimized - Lazy loading for large code blocks
🎨 Customizable - Fully customizable with Tailwind CSS
📱 Responsive - Works perfectly on all device sizes

Installation

Create New Project

# Create a new Next.js project with code blocks
npx @ajstudioz14151/codeblocks-component@latest create my-app

# Auto-create with default settings
npx @ajstudioz14151/codeblocks-component@latest create my-app --yes

Add to Existing Project

# Add code blocks to existing project
npx @ajstudioz14151/codeblocks-component@latest add

# Add with auto-confirm
npx @ajstudioz14151/codeblocks-component@latest add --yes

# Add specific components only
npx @ajstudioz14151/codeblocks-component@latest add codeblock
npx @ajstudioz14151/codeblocks-component@latest add toaster

Usage

Basic Example

import { CodeBlock } from '@/components/codeblocks/code-block';
import { Toaster } from '@/components/ui/toaster';

export default function MyPage() {
  const code = `function greeting(name) {
  console.log('Hello, ' + name + '!');
  return 'Welcome to AJ STUDIOZ Code Blocks';
}`;

  return (
    <div>
      <CodeBlock language="javascript" elementKey="demo">
        {code}
      </CodeBlock>
      <Toaster />
    </div>
  );
}

Advanced Example

import React, { useState } from 'react';
import { CodeBlock } from '@/components/codeblocks/code-block';

const examples = {
  javascript: `const numbers = [1, 2, 3, 4, 5];
const doubled = numbers.map(n => n * 2);
console.log(doubled);`,
  
  python: `def fibonacci(n):
    if n <= 1:
        return n
    return fibonacci(n-1) + fibonacci(n-2)`,
        
  css: `.button {
  background: linear-gradient(45deg, #667eea, #764ba2);
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
}`
};

export default function CodeExamples() {
  const [activeLanguage, setActiveLanguage] = useState('javascript');

  return (
    <div>
      <div className="flex gap-2 mb-4">
        {Object.keys(examples).map((lang) => (
          <button
            key={lang}
            onClick={() => setActiveLanguage(lang)}
            className={`px-3 py-1 rounded ${
              activeLanguage === lang ? 'bg-blue-500 text-white' : 'bg-gray-200'
            }`}
          >
            {lang}
          </button>
        ))}
      </div>
      
      <CodeBlock 
        language={activeLanguage} 
        elementKey={`example-${activeLanguage}`}
      >
        {examples[activeLanguage]}
      </CodeBlock>
    </div>
  );
}

Component API

CodeBlock Props

| Prop | Type | Required | Description | |------|------|----------|-------------| | children | string | ✅ | The code content to display | | language | string | ✅ | Programming language for syntax highlighting | | elementKey | string | ✅ | Unique key for the component instance |

Supported Languages

The component supports all languages supported by sugar-high:

  • JavaScript/TypeScript
  • Python
  • CSS/SCSS
  • HTML/XML
  • JSON
  • Markdown
  • And many more...

Dependencies

The CLI automatically installs these dependencies:

{
  "lucide-react": "Icons for copy/wrap buttons",
  "clsx": "Conditional CSS classes",
  "tailwind-merge": "Merge Tailwind classes",
  "sugar-high": "Syntax highlighting",
  "sonner": "Toast notifications"
}

Commands

create <project-name>

Creates a new Next.js project with code blocks components.

npx @ajstudioz14151/codeblocks-component@latest create my-app

Options:

  • --yes - Skip prompts and use defaults

add [component]

Adds code blocks components to existing project.

npx @ajstudioz14151/codeblocks-component@latest add
npx @ajstudioz14151/codeblocks-component@latest add codeblock
npx @ajstudioz14151/codeblocks-component@latest add toaster

Options:

  • --yes - Skip prompts and use defaults
  • --overwrite - Overwrite existing files

init

Initializes code blocks components in current directory (alias for add).

npx @ajstudioz14151/codeblocks-component@latest init

File Structure

After installation, your project will have:

src/
├── components/
│   ├── codeblocks/
│   │   └── code-block.tsx      # Simple wrapper component
│   └── ui/
│       ├── code-block.tsx      # Main CodeBlock component
│       └── toaster.tsx         # Toast notifications
├── lib/
│   └── utils.ts                # Utility functions
└── app/
    ├── codeblocks/
    │   └── page.tsx            # Demo page
    └── page.tsx                # Updated homepage

Customization

Styling

The components use Tailwind CSS and CSS variables. You can customize the appearance by:

  1. CSS Variables: Modify your theme colors in globals.css
  2. Tailwind Classes: Edit the component files directly
  3. Custom Themes: Use the cn() utility for conditional styling

Example Custom Styling

import { CodeBlock } from '@/components/codeblocks/code-block';

<CodeBlock 
  language="javascript" 
  elementKey="custom"
  className="my-custom-codeblock"
>
  {code}
</CodeBlock>
.my-custom-codeblock {
  @apply border-2 border-blue-500 rounded-2xl;
}

.my-custom-codeblock .code-header {
  @apply bg-blue-50 border-blue-200;
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

Support


Made with ❤️ by AJ STUDIOZ