Skip to content

Latest commit

 

History

History
36 lines (30 loc) · 750 Bytes

README.md

File metadata and controls

36 lines (30 loc) · 750 Bytes

preact-prism npm version

use Prism syntax highlighter in preact projects.

Install

npm install preact-prism

or

yarn add preact-prism

Example

import { h, render } from 'preact';
import Code from 'preact-prism';
import 'prismjs/themes/prism-solarizedlight.css'; /* import prism themes */

const code = `
.container {
  position: relative;
  height: 100%;
}
.inner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%)
}
`;

render(<Code code={code} language="css" />, document.body);
// or render(<Code language="css">{code}</Code>, document.body);