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

6.0.11 • 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

3,234

Version

6.0.11

License

BSD-3-Clause

Unpacked Size

105 kB

Total Files

14

Last publish

Collaborators

  • rexscaria
  • dcruz_cf
  • xuranwang
  • jculvey
  • sejoker
  • cf-radar
  • cf-ci-write
  • segments-write
  • thibmeu
  • xortive
  • gurjinder
  • cf-ci2
  • lvalenta
  • worenga
  • chiminator
  • third774
  • jasnell
  • terinjokes
  • celso
  • jsteinberger
  • gregbrimble
  • asapzacy
  • g4brym
  • wrangler-publisher
  • cf-media-manager
  • dash_service_account
  • jacobbednarz
  • lerwincf
  • simonabadoiu
  • cms1919
  • mgirouard-cf
  • musa-cf
  • vaishakpdinesh
  • ichernetsky-cf
  • jseba_cf
  • gabivlj-cf
  • ganders-cloudflare
  • nsharma-cf
  • mikenomitch
  • tlefebvre_cf
  • nafeezcf
  • eduardo-vargas
  • threepointone