Field

GitHub
清晰地展示文档 API 参数、props 和配置选项。

用法

用于在内容中显示的字段、prop 或参数。

name
字符串 必需
description 可以设置为 prop 或在默认插槽中,支持完整的 markdown
::field{name="name" type="string" required}
The `description` can be set as prop or in the default slot with full **markdown** support.
::

API

属性

属性默认值类型
as

'div'

any

此组件应渲染为的元素或组件。

name

string

字段的名称。

type

string

字段值的预期类型

description

string

字段的描述

required

boolean

指示字段是否必需

ui

{ root?: ClassNameValue; container?: ClassNameValue; name?: ClassNameValue; wrapper?: ClassNameValue; required?: ClassNameValue; type?: ClassNameValue; description?: ClassNameValue; }

插槽

插槽类型
default

{}

主题

app.config.ts
export default defineAppConfig({
  ui: {
    prose: {
      field: {
        slots: {
          root: 'my-5',
          container: 'flex items-center gap-3 font-mono text-sm',
          name: 'font-semibold text-primary',
          wrapper: 'flex-1 flex items-center gap-1.5 text-xs',
          required: 'rounded-sm bg-error/10 text-error px-1.5 py-0.5',
          type: 'rounded-sm bg-elevated text-toned px-1.5 py-0.5',
          description: 'mt-3 text-muted text-sm [&_code]:text-xs/4'
        }
      }
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'

export default defineConfig({
  plugins: [
    vue(),
    ui({
      ui: {
        prose: {
          field: {
            slots: {
              root: 'my-5',
              container: 'flex items-center gap-3 font-mono text-sm',
              name: 'font-semibold text-primary',
              wrapper: 'flex-1 flex items-center gap-1.5 text-xs',
              required: 'rounded-sm bg-error/10 text-error px-1.5 py-0.5',
              type: 'rounded-sm bg-elevated text-toned px-1.5 py-0.5',
              description: 'mt-3 text-muted text-sm [&_code]:text-xs/4'
            }
          }
        }
      }
    })
  ]
})

更新日志

6a6de— 功能:新组件 (#5200)

5cb65— 特性:导入 @nuxt/ui-pro 组件