ComponentProps
: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.
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 |
disabled | boolean | |
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
withDefaultsor a destructuring default; falls back to the JSDoc@defaultValuetag - 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
@seebecome links
<script setup lang="ts">
interface Props {
/**
* The variant of the component
* @defaultValue 'solid'
*/
variant?: 'solid' | 'outline' | 'soft' | 'subtle' | 'ghost' | 'link'
}
defineProps<Props>()
</script>
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[]需要忽略的属性名数组 |
prose | boolean |
Changelog
Content Components
Content components the layer adds on top of Nuxt UI prose. Motion adds entrance animations, StarsBg lays an animated star field behind a section, and LandingCover, LandingSection and friends build an editorial landing page. All work directly in Markdown.
ComponentSlots
List every slot of a Vue component with a single `:component-slots` line. Slot names, scoped parameter types and JSDoc descriptions come from the `defineSlots` type, so there is nothing to write by hand.