ComponentCode

ComponentCode lets authors drive the live rendering of any registered Vue component from a declarative property matrix in Markdown, while synthesizing a copy-paste Vue snippet in sync.

Usage

Basic usage

A minimal example: pass name (the PascalCase component name) and the initial props, with items providing the available options.

New
<template>
  <UBadge label="New" color="primary" variant="solid" />
</template>
::component-code
---
name: UBadge
props:
  label: New
  color: primary
  variant: solid
items:
  color: [primary, secondary, success, warning, error, neutral]
  variant: [solid, outline, soft, subtle]
---
::
ComponentCode and ComponentExample share the same ComponentExampleExtras extension component.

API

Props

Prop Default Type
namestring
propsRecord<string, any>
itemsRecord<string, any[]>
modelstring[]
hidestring[]
ignorestring[]
slotsRecord<string, any>
collapsefalseboolean | { icon?: string; name?: string; openText?: string; closeText?: string; open?: boolean; }

是否折叠代码块

highlightsnumber[]
prettierfalseboolean

是否使用 Prettier 格式化代码

overflowHiddenboolean
elevatedboolean

Changelog

No recent changes
Copyright © 2024 - 2026