# add-slot

Learn how to add slots to a project.

This action adds [slots](/explanation/slot) to the project, equivalent to the [`croct add slot`](/reference/cli/commands/add-slot) command.

A common pattern is to run it after [`create-resource`](/reference/cli/templates/actions/create-resource) to register the slots that were just provisioned in the workspace.

## Example

The following template creates an announcement bar component and slot in the workspace, then registers the slot in the project:

**template.json5**

```json5
{
  "$schema": "https://schema.croct.com/json/v1/template.json",
  "title": "Announcement bar",
  "description": "Creates and adds an announcement bar slot.",
  "actions": [
    {
      "name": "create-resource",
      "resources": {
        "components": {
          "top-bar": {
            "name": "Top bar",
            "schema": {
              "type": "structure",
              "attributes": {
                "message": {
                  "type": {
                    "type": "text"
                  },
                  "label": "Message",
                  "position": 0
                }
              }
            }
          }
        },
        "slots": {
          "announcement-bar": {
            "name": "Announcement bar",
            "component": "top-bar",
            "content": {
              "en": {
                "type": "structure",
                "attributes": {
                  "message": {
                    "type": "text",
                    "value": {
                      "type": "static",
                      "value": "Welcome to our site!"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    {
      "name": "add-slot",
      "slots": ["announcement-bar"],
      "example": true
    }
  ]
}
```

## Properties

These are the supported properties:

- `name`: `string`

  The action identifier. Always `add-slot` for this action.

- `slots`: `Array<string>`

  The list of [slots](/explanation/slot) to add.

  Each entry can be in the format `id` or `id@version`. When the version is omitted, the latest version is used.

- `example`: `boolean` (optional)

  Whether to generate example usage code for the added slots in the [examples path](/reference/cli/configuration#paths-examples-prop).

## Explore

- [Add component](/reference/cli/templates/actions/add-component): Learn how to install components into the project.
- [Create resource](/reference/cli/templates/actions/create-resource): Learn how to create components and slots in a workspace.
- [Write file](/reference/cli/templates/actions/write-file): Learn how to write rendering code for a slot.
- [Integrate Croct](/reference/cli/templates/actions/integrate-croct): Learn how to set up the Croct integration.
