<!--
{
  "availability" : [
    "Apple News Format: 1.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppleNewsFormat",
  "identifier" : "/documentation/AppleNewsFormat/DataTable",
  "metadataVersion" : "0.1.0",
  "role" : "Object",
  "symbol" : {
    "kind" : "Object",
    "modules" : [
      "Apple News Format"
    ],
    "preciseIdentifier" : "data:news_format:DataTable"
  },
  "title" : "DataTable"
}
-->

# DataTable

The component for adding a JSON data table.

```
object DataTable
```

## Discussion

Add a `DataTable` component that uses table data provided in a JSON format. Information about the table, including the data itself, is provided by the `data` property, whose value is a [`RecordStore`](/documentation/AppleNewsFormat/RecordStore) object that contains both the table data and information about the data, such as data types and header labels.

You can apply styles to table rows, columns, and cells using a [`ComponentStyle`](/documentation/AppleNewsFormat/ComponentStyle) object that has a [`TableStyle`](/documentation/AppleNewsFormat/TableStyle) defined.

### Example

```json
{
  "components": [
    {
      "role": "datatable",
      "showDescriptorLabels": true,
      "sortBy": [
        {
          "descriptor": "id-name",
          "direction": "descending"
        }
      ],
      "data": {
        "descriptors": [
          {
            "identifier": "id-name",
            "key": "name",
            "label": {
              "type": "formatted_text",
              "text": "Name",
              "textStyle": {
                "textColor": "black"
              }
            },
            "dataType": "string"
          },
          {
            "identifier": "id-occupation",
            "key": "occupation",
            "label": "Occupation",
            "dataType": "string"
          }
        ],
        "records": [
          {
            "name": "Amelia Earhart",
            "occupation": "Pilot"
          },
          {
            "name": "Grace Hopper",
            "occupation": "Computer Scientist"
          }
        ]
      },
      "style": {
        "tableStyle": {
          "rows": {
            "backgroundColor": "#fff",
            "divider": {
              "width": 1,
              "color": "#ddd"
            }
          },
          "headerRows": {
            "backgroundColor": "#ccc",
            "divider": {
              "width": 2,
              "color": "#999"
            }
          },
          "cells": {
            "padding": 6,
            "verticalAlignment": "top"
          }
        }
      },
      "layout": {
        "columnStart": 0,
        "columnSpan": 7,
        "margin": 20
      }
    }
  ]
}
```

## Relationships

### Inherits From

[`Component`](/documentation/AppleNewsFormat/Component)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)