Astryx

Astryx Code Block

Component

About

Fenced code block with syntax highlighting. Use for multi-line code snippets.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Astryx Code Block to your project and fits it to your theme.

Code

How Astryx Code Block is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

'use client';

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

const code = `interface User {
  id: string;
  name: string;
}

export function useUser(id: string) {
  const [user, setUser] = useState<User>();
  useEffect(() => {
    fetchUser(id).then(setUser);
  }, [id]);
  return user;
}`;

function CodeBlockHighlightedLines() {
  return (
    <CodeBlock
      code={code}
      language="typescript"
      title="useUser.ts"
      hasLineNumbers
      highlightLines={[8, 9, 10]}
    />
  );
}

export default function CodeBlockHighlightedLinesDemo() {
  return (
    <div
      data-astryx-theme="neutral"
      data-theme="light"
      style={{colorScheme: 'light', display: 'contents'}}>
      <CodeBlockHighlightedLines />
    </div>
  );
}

Dependencies

More by Astryx

View all
  • Astryx Banner

    Astryx Banner

    56
  • Astryx Aspect Ratio

    Astryx Aspect Ratio

    29
  • Astryx Avatar

    Astryx Avatar

    28
  • Astryx Badge

    Astryx Badge

    25
  • Astryx Button Group

    Astryx Button Group

    23
  • Astryx Chat Composer Drawer

    Astryx Chat Composer Drawer

    16
  • Astryx Toggle Button

    Astryx Toggle Button

    16
  • Astryx Avatar Group

    Astryx Avatar Group

    8