Get Started

Configuration

You can customise Prism’s settings using a PHP configuration file. This is optional: each setting has a default, so you only need to include the values you want to change.

To override a setting, create prism.php in your Craft project’s /config directory and return an array of setting names and values. For example, the following will show line numbers in the editor:

<?php

return [
    'editorLineNumbers' => true,
];

All other settings keep their defaults. Add any further settings you want to change to the same array. The options below explain the available settings and their defaults. You can also manage many of these settings in the control panel under Settings → Prism.

Configuration Options

editorTheme

Choose an editor theme.

editorLanguage

Choose a default syntax to highlight text with.

editorThemes

A collection of themes available for the field.

editorLanguages

A collection of languages available for the field.

editorHeight

Set the default number of rows the editor will be displayed at.

editorTabWidth

Set the tab width. This uses the experimental CSS property tab-size.

editorLineNumbers

Choose whether line numbers are displayed or not.

customThemesDir

The path to the theme directory where your custom CSS files are located.

Themes

You can show specific themes by listing the style handles e.g. ['prism-coy','prism-dark']. Custom themes are specified by adding a key => value entry e.g. ['prism-my-custom-theme' => 'My Custom Title'].

'themes' => ['*', 'prism-my-custom-theme' => 'My Custom Title'],

Note: Custom themes must follow these rules:

  • Exist in a directory specified on the plugin settings screen
  • Be named after the handle. E.g prism-my-custom-theme.css
  • Be namespaced after the theme name e.g. .prism-my-custom-theme .token { color: #000 } - This is to prevent conflicts with Craft's styles

Languages

Languages are configurable in the same way as themes. Use ['*'] to show all 177 languages, or just list the ones you'd like to show in the config. Custom languages aren't supported at this time, but may be in the future.