JGuang

元信息列表

MetadataList · Astryx

交互预览
npm install @astryxdesign/core@0.7.1 @astryxdesign/theme-neutral@0.7.1 @stylexjs/stylex@0.19.0

元信息列表 · MetadataList

元信息列表用于表格与列表场景。下面的官方示例展示原生用法与状态,属性名保持上游 API。

安装与前置条件

npm install @astryxdesign/core@0.7.1 @astryxdesign/theme-neutral@0.7.1 @stylexjs/stylex@0.19.0

需要 React 19+,按顺序导入基础 CSS 和主题,并设置 Theme Provider。参见开始使用。

示例与使用方式

  • 元信息列表 · 综合展示 1:首先体验这个示例,再查看代码理解组件的组合方式。
  • 元信息列表 · 综合展示 2:可交互查看这一用法的行为,复制代码时保留它实际使用的属性与导入。
  • 元信息列表 · 基础用法 3:可交互查看这一用法的行为,复制代码时保留它实际使用的属性与导入。
  • 元信息列表 · 交互示例 4:可交互查看这一用法的行为,复制代码时保留它实际使用的属性与导入。
  • 元信息列表 · 交互示例 5:可交互查看这一用法的行为,复制代码时保留它实际使用的属性与导入。
  • 元信息列表 · 基础用法 6:可交互查看这一用法的行为,复制代码时保留它实际使用的属性与导入。
  • 元信息列表 · 交互示例 7:可交互查看这一用法的行为,复制代码时保留它实际使用的属性与导入。

API 与上游详细参考

优先使用 0.7.1 官方中文说明;上游尚未提供中文的条目保留英文。属性名、类型及默认值保持原生 API,不把示例状态名称当成组件属性。

Metadata List

MetadataList displays key-value pairs for object attributes like quality, condition, and status, in a structured layout. Use it for detail panels, settings summaries, and record information.

属性类型默认值说明
children *ReactNodeMetadata items (MetadataListItem components).
columns'multi' | 'single' | number'single'Column layout mode.
label{ position?: 'start' | 'top', width?: number | string }{ position: 'start' } (single-column) / { position: 'top' } (multi-column)Label display configuration. position controls label placement, width sets a custom label column width. Defaults to { position: 'top' } for multi-column layouts.
maxNumOfItemsnumberMaximum items to show before collapsing with a show more/less toggle.
orientation'vertical' | 'horizontal''vertical'Layout orientation. Horizontal mode flows items in a row with flex-wrap.
titleReactNodeOptional title or heading above the list.
xstyleStyleXStylesStyleX styles for layout customization. Must be a stylex.create() value.

使用建议

  • Choose label position based on content: "start" for short values, "top" for long or complex values.
  • Collapse long lists with maxNumOfItems to keep the page scannable.
  • 避免:Use for extensive form input; use a form layout instead.
  • 避免:Use for data that doesn't have a clear key-value structure.

主题 API

{
  "targets": [
    {
      "className": "astryx-metadata-list",
      "visualProps": [
        "columns",
        "orientation"
      ]
    },
    {
      "className": "astryx-metadata-list-item"
    }
  ]
}

MetadataListItem

组件结构

  • Title: Optional title for the metadata list.
  • Label: The key label for each metadata entry.
  • Metadata: The value displayed in various formats.
  • Disclosure: Collapse/expand control for the list.

Metadata List Item

MetadataList 中的单个带标签元数据值。

属性类型默认值说明
children *ReactNode此元数据项的内容值。
label *string此元数据项的标签文本。
iconReactNode标签文本前渲染的图标。