CodeInline

Renders an inline code element with optional syntax highlighting and copy button.

MDX Inline Code

When using MDX with the rehypePlugins from renoun/mdx you can prefix the inline code with a language similar to fenced code blocks. For example:

When using inline code `js console.log('Hello, World!')`, you can specify the language for syntax highlighting.

When using inline code js console.log('Hello, World!'), you can specify the language for syntax highlighting.

Examples

  • In React, <span style={{ color: 'blue' }} /> changes the color of the text to blue.

    import { CodeInline } from 'renoun/components'
    
    export function Basic() {
      return (
        <p>
          In React,{' '}
          <CodeInline language="jsx">{`<span style={{ color: 'blue' }} />`}</CodeInline>{' '}
          changes the color of the text to blue.
        </p>
      )
    }
  • Allow Copy

    View Source
    npx create-renoun
    import { CodeInline } from 'renoun/components'
    
    export function AllowCopy() {
      return (
        <CodeInline allowCopy language="sh" paddingX="0.8em" paddingY="0.5em">
          npx create-renoun
        </CodeInline>
      )
    }

API Reference