Schema File
The optional schema.json file defines the widget’s attribute contract. It specifies the attributes and their associated Lightning types that the widget accepts, including display metadata (such as title and description for attribute). The Lightning types determine validation rules and data types for each attribute.
To use attribute mapping to connect your widget to a Lightning type’s dynamic data, include a schema.json file. Without it, the widget can only display static, hardcoded values.
Note
The schema file enables:
- Design-time validation of data bindings between Lightning types and Widgets
- Runtime binding of attributes to enable dynamic widget behavior
This table lists the keywords that you can specify for individual widget attributes.
| Keyword | Description |
|---|---|
title | The display name for the attribute. |
description | A brief explanation of the attribute’s purpose. |
lightning:type | The Lightning type reference for the attribute, such as lightning__textType, lightning__numberType, or lightning__urlType. |
This template shows the standard structural composition for defining a widget schema file.
1{
2 "title": "Widget Schema Title",
3 "description": "Description of the widget's attribute contract",
4 "properties": {
5 "attributes": {
6 "type": "object",
7 "properties": {
8 "Name": {
9 "title": "Display Name",
10 "description": "Description shown in Widget Builder",
11 "lightning:type": "lightning__textType"
12 }
13 }
14 }
15 }
16}This example shows a schema.json configuration file for a hotel card widget, establishing the expected data types and display metadata for the widget attributes.
1{
2 "title": "Hotel Card Widget",
3 "description": "Displays hotel information as a visual card",
4 "type": "object",
5 "properties": {
6 "attributes": {
7 "lightning:type": "lightning__objectType",
8 "properties": {
9 "title": {
10 "title": "Hotel Name",
11 "description": "Primary heading displayed at the top",
12 "lightning:type": "lightning__textType"
13 },
14 "imageUrl": {
15 "title": "Image URL",
16 "description": "URL of the hotel image",
17 "lightning:type": "lightning__urlType"
18 },
19 "price": {
20 "title": "Price Per Night",
21 "description": "Nightly rate displayed as currency",
22 "lightning:type": "lightning__numberType"
23 },
24 "description": {
25 "title": "Description",
26 "description": "Short description of the hotel",
27 "lightning:type": "lightning__textType"
28 }
29 }
30 }
31 }
32}Beta Feature