CodePreview

GitHub
Display code examples with a preview and their source for clearer documentation.

Usage

Wrap any content with the code-preview component to display a live preview alongside its source code using the code slot.

inline code

`inline code`
::code-preview
`inline code`

#code
```mdc
`inline code`
```
::

API

Props

Prop Default Type

Slots

Slot Type

Theme

We use unocss-variants to customize the theme. Read more about it in the theming guide.

Below is the theme configuration skeleton for the ProseCodePreview. Since the component is provided unstyled by default, you will need to fill in these values to apply your own custom look and feel. If you prefer to use our pre-built, opinionated styling, you can instead use our UnoCSS preset, this docs is using it as well.

app.config.ts
export default defineAppConfig({
  pohon: {
    prose: {
      codePreview: {
        slots: {
          root: '',
          preview: '',
          code: ''
        },
        variants: {
          code: {
            true: {
              preview: ''
            }
          }
        }
      }
    }
  }
};
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import pohon from 'pohon-ui/vite'

export default defineAppConfig({
  pohon: {
    prose: {
      codePreview: {
        slots: {
          root: '',
          preview: '',
          code: ''
        },
        variants: {
          code: {
            true: {
              preview: ''
            }
          }
        }
      }
    }
  }
};

Changelog

No recent changes