# Shiki

> Syntax highlighting with VS Code's grammars and themes: accurate, themeable code blocks.

Source: https://tastebase.ehsanulsiam.workers.dev/browse/shiki

free

Syntax highlighting with VS Code's grammars and themes: accurate, themeable code blocks.

by Pine Wu and Anthony Fu[GitHub](https://github.com/shikijs/shiki)[npm](https://npmjs.com/package/shiki)

[visit](https://shiki.style/?utm_source=tastebase&utm_medium=referral&utm_content=detail-page)

[https://shiki.style](https://shiki.style/?utm_source=tastebase&utm_medium=referral&utm_content=detail-preview)

## Try these

no preview

### [shadcn/ui](https://tastebase.ehsanulsiam.workers.dev/browse/shadcn-ui)

Copy-in React components on Tailwind, built on Base UI, Radix or React Aria, plus a registry CLI.

no preview

### [Lucide](https://tastebase.ehsanulsiam.workers.dev/browse/lucide)

Clean 24px stroke icons, one component per icon, the default set for shadcn/ui.

no preview

### [visx](https://tastebase.ehsanulsiam.workers.dev/browse/visx)

Airbnb's low-level D3 + React primitives (scales, shapes, axes) for custom charts.

no preview

### [nivo](https://tastebase.ehsanulsiam.workers.dev/browse/nivo)

Rich, themeable React charts in SVG, canvas or HTML, with motion and patterns built in.

## For your agent

##### Install

`npm i shiki`

##### Use it for

- a code sample on a developer landing page or API product page
- code blocks in docs, a blog or a changelog, highlighted the way VS Code shows them
- a snippet with light and dark themes that follow the site's colour scheme

##### Skip it when

- a code editor with syntax highlighting, where people type and edit code: Shiki only displays it; use CodeMirror or Monaco
- a page that must ship almost no JavaScript and only shows one short snippet: highlight it at build time or style a plain pre

##### What's inside28 free

- Themes
- Languages
- Dual Themes
- Bundles
- Shorthands
- Decorations
- Transformers
- Theme Colors Manipulation
- RegExp Engines
- Synchronous Usage
- Grammar State
- Custom Themes
- Custom Languages
- TypeScript Twoslash
- markdown-it
- markdown-exit
- Rehype
- Monaco Editor
- VitePress
- Nuxt
- Next
- Astro
- Common Transformers
- Colorized Brackets
- Magic Move
- Stream
- Codegen
- CLI

##### Facts

**Frameworks**
react, vue, svelte, solid, angular, vanilla

**Styling**
css

**Weight**
medium

**Accessibility**
ok

**Maturity**
established

**License**
MIT

**Price**
Free

##### Pairs with

[shadcn/ui](https://tastebase.ehsanulsiam.workers.dev/browse/shadcn-ui)[Lucide](https://tastebase.ehsanulsiam.workers.dev/browse/lucide)

```
import { useEffect, useState } from 'react'
import { codeToHtml } from 'shiki/bundle/web'

function Code({ code, lang = 'ts' }: { code: string; lang?: 'ts' | 'tsx' | 'bash' | 'json' }) {
  const [html, setHtml] = useState<string>()
  useEffect(() => { codeToHtml(code, { lang, themes: { light: 'github-light', dark: 'github-dark' } }).then(setHtml) }, [code, lang])
  if (!html) return <pre><code>{code}</code></pre>
  return <div className="text-sm [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:p-4" dangerouslySetInnerHTML={{ __html: html }} />
}
```

https://shiki.style

Loading website

[Visit](https://shiki.style/?utm_source=tastebase&utm_medium=referral&utm_content=floating-pill)
