ComponentProps

Generate a props table for a Vue component with a single :component-props line. Names, defaults, types and JSDoc descriptions come from nuxt-component-meta, so the docs stay in sync with the component.

ComponentProps reads a component's defineProps and renders the name, default value, type and JSDoc description of every prop as a table.

Component docs are disabled by default. Before using this page and ComponentSlots, ComponentEmits, ComponentExample or ComponentCode, set movkNuxtDocs.componentDocs: true in nuxt.config.ts and install nuxt-component-meta, vue-component-meta and prettier.

Usage

Pass the component name with slug:

Prop Default Type
color'primary' "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral"
size'md' "xs" | "sm" | "md" | "lg" | "xl"
variant'solid' "solid" | "outline" | "soft" | "subtle" | "ghost" | "link"

The variant of the component

disabledboolean
label string
avatar { src: string; alt?: string | undefined; text?: string | undefined; chip?: boolean | "circle" | undefined; size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined; }

display an avatar

:component-props{slug="TestApi"}

Infer the component from the route

Without slug, the last segment of the current route is converted to PascalCase, so /docs/components/button maps to Button. When each component has its own page named after it, :component-props is enough.

Ignore props

Use ignore to hide props from the table. By default the routing props forwarded to NuxtLink (href, prefetch, replace and so on) and form props (form, formaction and so on) are hidden; passing ignore replaces that default list:

:component-props{slug="TestApi" :ignore='["disabled", "avatar"]'}

Prose components

With prose, the Prose prefix is added to the name, so :component-props{prose} on the mermaid page maps to ProseMermaid.

Where the data comes from

The table is built from the types and comments in the component source:

  • Default: taken from withDefaults or a destructuring default; falls back to the JSDoc @defaultValue tag
  • Type: enum types are expanded into unions, object types can be expanded to show nested fields
  • Description: the JSDoc body is rendered as Markdown and tags such as @see become links
components/TestApi.vue
<script setup lang="ts">
interface Props {
  /**
   * The variant of the component
   * @defaultValue 'solid'
   */
  variant?: 'solid' | 'outline' | 'soft' | 'subtle' | 'ghost' | 'link'
}

defineProps<Props>()
</script>
Components in your project's app/components/ and components/ directories get no metadata by default. Add the ones you document to componentMeta.include, for example componentMeta: { include: ['app/components/TestApi.vue'] }. include accepts paths, globs, regular expressions and functions.

API

Props

Prop Default Type
slug路由路径的最后一段 string

获取组件属性的 slug 标识

ignore[ "activeClass", "inactiveClass", "exactActiveClass", "ariaCurrentValue", "href", "rel", "noRel", "prefetch", "prefetchOn", "noPrefetch", "prefetchedClass", "replace", "exact", "exactQuery", "exactHash", "external", "onClick", "viewTransition", "enterKeyHint", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget" ] string[]

需要忽略的属性名数组

proseboolean

Changelog

No recent changes
Copyright © 2024 - 2026