Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shredderming/preact-prism

Preact syntax highlighting component using prism
https://github.com/shredderming/preact-prism

highlight preact preact-components prism

Last synced: 4 days ago
JSON representation

Preact syntax highlighting component using prism

Awesome Lists containing this project

README

        

# preact-prism [![npm version](https://img.shields.io/npm/v/preact-prism.svg?style=flat)](https://www.npmjs.com/package/preact-prism)
use [Prism](http://prismjs.com) syntax highlighter in preact projects.
## Install

``` sh
npm install preact-prism
```
or

``` sh
yarn add preact-prism
```
## Example

``` js
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(, document.body);
// or render({code}, document.body);
```