@cloudflare/component-code-block
TypeScript icon, indicating that this package has built-in type declarations

5.0.16 • Public • Published

component-code-block

Syntax highlighting for your code!

This uses the PrismJS highlighter to highlight code passed to it, with support for all the usual language suspects (JS, TS etc...) plus a few custom ones for Cloudflare (sh for shell scripts, and toml for TOMl).

API

This library exports two components:

import CodeBlock, { TabbedCodeBlock } from "@cloudflare/component-code-block"

The CodeBlock component is what you'll use if you need a single highlighted code block:

<CodeBlock language="js" code="console.log('hi')"/>

TabbedCodeBlock is what you'll use if you need to support multiple languages (or options) for a single code block, which will render with tabs for each option:

<TabbedCodeBlock options={{npm: {language: 'sh', code: 'npm i left-pad'}, yarn: {language: 'sh', code: 'yarn add left-pad'}}} />

## Installation

```sh
$ npm install @cloudflare/component-code-block

Readme

Keywords

none

Package Sidebar

Install

npm i @cloudflare/component-code-block

Weekly Downloads

1,440

Version

5.0.16

License

BSD-3-Clause

Unpacked Size

96.8 kB

Total Files

14

Last publish

Collaborators

  • lbarthonet
  • cf-media-manager
  • jacobbednarz
  • celso
  • cf-radar
  • dash_service_account
  • g4brym
  • snigdha34
  • wrangler-publisher
  • marksteyn
  • chiminator
  • sgoodhew_cf
  • terinjokes
  • third774
  • jsteinberger
  • jasnell
  • asapzacy
  • pcostanzo
  • gregbrimble
  • geelen
  • rexscaria
  • dcruz_cf
  • xuranwang
  • jculvey
  • sejoker
  • vasturiano
  • cf-ci-write
  • segments-write
  • thibmeu
  • xortive
  • gurjinder
  • cf-ci2
  • lvalenta
  • worenga