Skip to content

Configure Highlighter ​

Slidev uses Shiki as the code highlighter. It's a TextMate Grammar powered syntax highlighter as accurate as VS Code. It generates colored tokens so no additinal CSS is required. Shiki also comes with a bunch of built-in themes. In Slidev, we also provided the TwoSlash support.

Configure Shiki ​

Environment: both
This setup function will run on both Node.js and client side. Avoid using Node.js or DOM API to prevent runtime errors.

Create ./setup/shiki.ts file with the following content:

setup/shiki.ts
ts
import {  } from '@slidev/types'

export default (() => {
  return {
    : {
      : 'min-dark',
      : 'min-light',
    },
    : [
      // ...
    ],
  }
})

If you want to add custom theme or language (TextMate grammar/themes in JSON), you can import them in the setup file:

setup/shiki.ts
ts
import {  } from '@slidev/types'
import  from './customLanguage.tmLanguage.json'
import  from './customTheme.tmTheme.json'

export default (() => {
  return {
    : {
      : ,
      : 'min-light',
    },
    : [
      'js',
      'typescript',
      'cpp',
      ,
      // ...
    ],
    : [
      // ...
    ],
  }
})

Check Built-in languages and Built-in themes, and refer to Shiki's docs for more details.

INFO

For now, Shiki Magic Move does not support transformers.

Configure Prism ​

WARNING

Prism support has been removed since v0.50. Please use Shiki instead.

Released under the MIT License.