CodeCollapse

GitHub
Make long code blocks collapsible to save space and improve readability.

Usage

Wrap your code-block with a code-collapse component to display a collapsible code block.

main.css
@theme static {
  --font-sans: 'Public Sans', sans-serif;

  --breakpoint-3xl: 1920px;

  --color-green-50: #effdf5;
  --color-green-100: #d9fbe8;
  --color-green-200: #b3f5d1;
  --color-green-300: #75edae;
  --color-green-400: #00dc82;
  --color-green-500: #00c16a;
  --color-green-600: #00a155;
  --color-green-700: #007f45;
  --color-green-800: #016538;
  --color-green-900: #0a5331;
  --color-green-950: #052e16;
}
::code-collapse

```css [main.css]
@theme static {
  --font-sans: 'Public Sans', sans-serif;

  --breakpoint-3xl: 1920px;

  --color-green-50: #EFFDF5;
  --color-green-100: #D9FBE8;
  --color-green-200: #B3F5D1;
  --color-green-300: #75EDAE;
  --color-green-400: #00DC82;
  --color-green-500: #00C16A;
  --color-green-600: #00A155;
  --color-green-700: #007F45;
  --color-green-800: #016538;
  --color-green-900: #0A5331;
  --color-green-950: #052E16;
}
```

::

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 ProseCodeCollapse. 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: {
      codeCollapse: {
        slots: {
          root: '',
          footer: '',
          trigger: '',
          triggerIcon: ''
        },
        variants: {
          open: {
            true: {
              root: ''
            },
            false: {
              root: '',
              footer: ''
            }
          }
        }
      }
    }
  }
};
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import pohon from 'pohon-ui/vite'

export default defineAppConfig({
  pohon: {
    prose: {
      codeCollapse: {
        slots: {
          root: '',
          footer: '',
          trigger: '',
          triggerIcon: ''
        },
        variants: {
          open: {
            true: {
              root: ''
            },
            false: {
              root: '',
              footer: ''
            }
          }
        }
      }
    }
  }
};

Changelog

No recent changes