Observed since 20 Oct, 22:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0x1js/highlighter
Lightweight, beautiful syntax highlighter for JavaScript, TypeScript, and Bash
Lightweight, beautiful code highlighting for your 0x1 applications
A fast, customizable syntax highlighter built specifically for the 0x1 Framework with support for JavaScript, TypeScript, Bash, and more. Features beautiful themes, copy-to-clipboard functionality, and seamless React integration.
# Install the package
bun add @0x1js/highlighter
# Or with npm
npm install @0x1js/highlighter
import { SyntaxHighlighter } from '@0x1js/highlighter';
import '@0x1js/highlighter/styles';
function MyComponent() {
const code = `
const { useState } = require('0x1');
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>
Increment
</button>
</div>
);
}
`;
return (
<SyntaxHighlighter
language="javascript"
theme="violet"
showLineNumbers
title="Counter Component"
copyable
>
{code}
</SyntaxHighlighter>
);
}
import { highlight } from '@0x1js/highlighter';
import '@0x1js/highlighter/styles';
const code = `
function greet(name) {
console.log(\`Hello, \${name}!\`);
}
`;
const highlightedHTML = highlight(code, {
language: 'javascript',
theme: 'dark',
showLineNumbers: true
});
document.getElementById('code-container').innerHTML = highlightedHTML;
<SyntaxHighlighter language="javascript" theme="dark">
{code}
</SyntaxHighlighter>
<SyntaxHighlighter language="javascript" theme="light">
{code}
</SyntaxHighlighter>
<SyntaxHighlighter language="javascript" theme="violet">
{code}
</SyntaxHighlighter>
interface HighlightOptions {
language: 'javascript' | 'typescript' | 'bash' | 'json' | 'html' | 'css';
theme?: 'dark' | 'light' | 'violet';
showLineNumbers?: boolean;
startLineNumber?: number;
maxLines?: number;
wrapLines?: boolean;
}
interface SyntaxHighlighterProps extends HighlightOptions {
children: string;
className?: string;
style?: React.CSSProperties;
copyable?: boolean;
title?: string;
footer?: string;
onCopy?: (code: string) => void;
}
{/* TypeScript */}
<SyntaxHighlighter language="typescript" theme="violet">
{tsCode}
</SyntaxHighlighter>
{/* Bash commands */}
<SyntaxHighlighter language="bash" theme="dark">
{`#!/bin/bash
cd /path/to/project
bun install
bun run build`}
</SyntaxHighlighter>
{/* JSON data */}
<SyntaxHighlighter language="json" theme="light" showLineNumbers>
{jsonData}
</SyntaxHighlighter>
<SyntaxHighlighter
language="typescript"
theme="violet"
showLineNumbers
startLineNumber={10}
maxLines={50}
title="API Routes"
footer="src/api/users.ts"
className="my-custom-class"
style={{ marginBottom: '2rem' }}
onCopy={(code) => console.log('Copied:', code)}
>
{code}
</SyntaxHighlighter>
import { InlineCode } from '@0x1js/highlighter';
<p>
Use <InlineCode>console.log()</InlineCode> for debugging.
</p>
import { useHighlight } from '@0x1js/highlighter';
function CodeBlock({ code, language }) {
const highlightedHTML = useHighlight(code, {
language,
theme: 'violet',
showLineNumbers: true
});
return (
<div
className="syntax-highlighter theme-violet"
dangerouslySetInnerHTML={{ __html: highlightedHTML }}
/>
);
}
// Works great with SSR
import { highlight } from '@0x1js/highlighter';
export function generateStaticHTML(code) {
return highlight(code, {
language: 'javascript',
theme: 'dark',
showLineNumbers: true
});
}
Get all supported languages:
import { getSupportedLanguages } from '@0x1js/highlighter';
console.log(getSupportedLanguages());
// ['javascript', 'typescript', 'bash', 'json', 'html', 'css']
// Use the main component with language prop
import { SyntaxHighlighter } from '@0x1js/highlighter';
<SyntaxHighlighter language="typescript" theme="dark">
{code}
</SyntaxHighlighter>
// Individual language components work but are unnecessary
import { TypeScriptHighlighter } from '@0x1js/highlighter';
<TypeScriptHighlighter theme="dark">
{code}
</TypeScriptHighlighter>
/* Override theme colors */
.syntax-highlighter.theme-custom {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #ffffff;
}
.theme-custom .token-keyword {
color: #ffd700;
font-weight: bold;
}
.theme-custom .token-string {
color: #98fb98;
}
# Build the package
bun run build
# Development with watch mode
bun run dev
MIT © 0x1 Framework
We welcome contributions! Please feel free to submit a Pull Request.
Made with ❤️ for the 0x1 Community
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
@types/bunEnvironment{
"local_name": "@types/bun",
"alias": false,
"peer_metadata": null
} | latest | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^5.0.0 | development |
@types/reactEnvironment{
"local_name": "@types/react",
"alias": false,
"peer_metadata": null
} | ^18.0.0 | development |
0x1Environment{
"local_name": "0x1",
"alias": false,
"peer_metadata": null
} | * | peer |
reactEnvironment{
"local_name": "react",
"alias": false,
"peer_metadata": null
} | ^18.0.0 | peer |
Source distribution
{
"shasum": "029dad3a8c169f747978713380d1f36e234565ec",
"tarball": "https://registry.npmjs.org/@0x1js/highlighter/-/highlighter-0.1.0.tgz",
"fileCount": 7,
"integrity": "sha512-dEDPp65e7c9mZwxhBgE5LHXW7q1GHaAfSrGXFEyCiOxZPEq5KPWqY09Ze146UJZ5UDxwEPF7vJnuuHVVRUKclA==",
"signatures": [
{
"sig": "MEUCIE1xrAjDe7sf/S6s9Wr9xB+hPBQKLh91j2nF37iT3mTlAiEA/6lDmA5IZnplG36TzM7NrqSsbxRB/Yc7yHSfg2jFk3o=",
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
}
],
"unpackedSize": 292741
}Observed since 20 Oct, 22:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:3d5ffd55d8e363cfb93e87b71b17aa9e6b59a898203182d339daf92809107aa2