> For the complete documentation index, see [llms.txt](https://docs.avonnicomponents.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avonnicomponents.com/dynamic-components/components/lwc-container.md). Agents can also search and read this documentation through its [MCP server](https://docs.avonnicomponents.com/~gitbook/mcp).

# LWC Container

Show a custom Lightning Web Component inside a Dynamic Component, feed it values from the page and run interactions when it fires an event.

## Overview

The LWC Container shows a Lightning Web Component written by your team (or shipped in a managed package) inside a Dynamic Component. You give it the component's name, pass it values from the page, such as the account selected in a Data Table, and run interactions when the LWC fires an event.

Typical use: an account manager reviews accounts in a Data Table, and a custom "account snapshot" LWC beside it shows the account they select, with a button that sends a review request.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2F3LRyYCyXB1UNFTTmQpMo%2Flwc-container-result.png?alt=media" alt="A Data Table of accounts with one row selected and a custom account snapshot LWC beside it showing that account&#x27;s industry, rating and revenue"><figcaption><p>The LWC Container shows a custom LWC fed by the account selected in the table.</p></figcaption></figure>

{% hint style="info" %}
The LWC Container runs no query of its own. If your LWC should display records with Avonni search, filters and pagination around them, use the [Data LWC Container](https://docs.avonnicomponents.com/dynamic-components/components/data-lwc-container.md) instead. [Data LWC Container or LWC Container?](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/data-lwc-container/data-lwc-container-or-lwc-container.md) compares the two.
{% endhint %}

## Tutorials

Step-by-step guides for this component live in [LWC Container tutorials](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/lwc-container.md).

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Pass a Selected Row to an LWC</strong></td><td>Send the account a user selects in a Data Table to your custom LWC, so it always shows the row in focus.</td><td><a href="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FjbHBVZWu7unonjfSRLVV%2Flwc-container-cover-pass-a-selected-row-to-an-lwc.png?alt=media">lwc-container-cover-pass-a-selected-row-to-an-lwc.png</a></td><td><a href="https://docs.avonnicomponents.com/dynamic-components/tutorials/components/lwc-container/pass-a-selected-row-to-an-lwc.md">Pass a Selected Row to an LWC</a></td></tr><tr><td><strong>React to an LWC Event</strong></td><td>Let a button inside your LWC run an Avonni interaction, such as a toast or a flow.</td><td><a href="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2F0ju978UrNp4OFkeJf7Lz%2Flwc-container-cover-react-to-an-lwc-event.png?alt=media">lwc-container-cover-react-to-an-lwc-event.png</a></td><td><a href="https://docs.avonnicomponents.com/dynamic-components/tutorials/components/lwc-container/react-to-an-lwc-event.md">React to an LWC Event</a></td></tr><tr><td><strong>Show a Placeholder in the Builder</strong></td><td>Show a clear placeholder on the builder canvas and a badge in Preview with Is Builder and Is Preview.</td><td><a href="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2F2unsCYGaZ7D93Edb54bp%2Flwc-container-cover-show-a-placeholder-in-the-builder.png?alt=media">lwc-container-cover-show-a-placeholder-in-the-builder.png</a></td><td><a href="https://docs.avonnicomponents.com/dynamic-components/tutorials/components/lwc-container/show-a-placeholder-in-the-builder.md">Show a Placeholder in the Builder</a></td></tr><tr><td><strong>Embed a Managed Package Component</strong></td><td>Check whether a managed package or OmniStudio component loads by name, and wrap it when it does not.</td><td><a href="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FaNlqTIyzp1hKiJHoZwIU%2Flwc-container-cover-embed-a-managed-package-component.png?alt=media">lwc-container-cover-embed-a-managed-package-component.png</a></td><td><a href="https://docs.avonnicomponents.com/dynamic-components/tutorials/components/lwc-container/embed-a-managed-package-component.md">Embed a Managed Package Component</a></td></tr></tbody></table>

## Configuration

Select the LWC Container on the canvas. The **Edit Lwc Container** panel opens on the right, with the **Properties**, **Interactions** and **Style** tabs.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FYts1D4wLGxmkJsP8CnoK%2Flwc-container-properties.png?alt=media" alt="The LWC Container Properties tab with LWC Name, one LWC Attributes item and the two attribute name settings" width="320"><figcaption><p>LWC Name, LWC Attributes and the two advanced attribute names.</p></figcaption></figure>

### Properties

#### LWC Name

The name of the Lightning Web Component to display, namespace included, in the form `namespace/componentName`: `c/accountSnapshot` for a component deployed in your org, `yourNamespace/componentName` for one from a managed package. The field also accepts a resource, so the name can come from a Variable or a Formula.

The other properties appear once **LWC Name** is filled in.

#### LWC Attributes

Requires **LWC Name** to be set.

The values passed to the LWC's `@api` properties. Add one item per property:

| Field     | What to enter                                                                                                                           | Example                                       |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
| **Name**  | The `@api` property name, exactly as written in the LWC's JavaScript (case-sensitive)                                                   | `accountId`                                   |
| **Value** | A fixed value, or a resource picked with the resource selector: a Variable, a Formula, another component's attribute, a global variable | `{!AccountsTable.firstSelectedRowSObject.Id}` |

Other common values: `{!$Component.RecordId}` for the record the page is showing (it needs the [Target Page Object](https://docs.avonnicomponents.com/dynamic-components/core-concepts/target-page-object.md)), `{!YourVariable}` for a Variable. [Using Variables and Component Data](https://docs.avonnicomponents.com/dynamic-components/core-concepts/using-variables-and-component-data.md) lists what each component exposes.

{% hint style="warning" %}
A value typed by hand reaches the LWC as text. `true` arrives as the text `"true"`, and `5` as `"5"`. When the LWC expects a boolean or a number, pass a Variable or a Formula of that type, or convert the value in the LWC.
{% endhint %}

#### Is Builder Attribute Name

Requires **LWC Name** to be set. Advanced option.

The `@api` property of the LWC that receives `true` while the component is shown on the builder canvas. Default: `isBuilder`. Change it only when the LWC already uses another name for that flag.

#### Is Preview Attribute Name

Requires **LWC Name** to be set. Advanced option.

The `@api` property of the LWC that receives `true` while the component runs in the builder's Preview. Default: `isPreview`.

[Show a Placeholder in the Builder](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/lwc-container/show-a-placeholder-in-the-builder.md) shows what an LWC can do with both flags.

#### Set Component Visibility

All components support conditional visibility. See [Component Visibility](https://docs.avonnicomponents.com/dynamic-components/core-concepts/component-visibility.md).

## Use Cases

### Show the selected account in a custom LWC

{% stepper %}
{% step %}

#### Add the two components

Drag a **Data Table** and an **LWC Container** onto the canvas. Give the Data Table the **API Name** `AccountsTable`, set its query on Account and its **Max Row Selection** to `1`.
{% endstep %}

{% step %}

#### Name the LWC

Select the LWC Container and set **LWC Name** to `c/accountSnapshot`.
{% endstep %}

{% step %}

#### Pass the selected account

In **LWC Attributes**, add an item with **Name** `accountId` and **Value** `{!AccountsTable.firstSelectedRowSObject.Id}`.
{% endstep %}

{% step %}

#### Test it in Preview

Open Preview and select an account in the table. The snapshot shows that account.
{% endstep %}
{% endstepper %}

The full walkthrough, with the LWC's code, is [Pass a Selected Row to an LWC](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/lwc-container/pass-a-selected-row-to-an-lwc.md).

### Embed a managed package component

The container loads any Lightning Web Component deployed to your org with `isExposed` set to `true` in its `.js-meta.xml`, whether your team wrote it or it comes from a managed package. A managed package component is named with its namespace: `industryNamespace/componentName`.

| Component type                                       | Loads in the LWC Container?                                                                                                                    |
| ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| Custom LWC built by your team                        | Yes                                                                                                                                            |
| Managed package LWC (Industries clouds, ISV apps)    | Yes, when it is exposed. Some managed components limit which `@api` properties you can set.                                                    |
| Screen Flow                                          | Use the [Flow](https://docs.avonnicomponents.com/dynamic-components/components/flow.md) component instead: it maps input and output variables. |
| Aura component                                       | No                                                                                                                                             |
| OmniScript or FlexCard on the legacy Vlocity runtime | No. One deployed on the LWC runtime may load as an LWC; a legacy one needs migrating to the LWC runtime first.                                 |

[Embed a Managed Package Component](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/lwc-container/embed-a-managed-package-component.md) covers how to check a component before you try it, and the wrapper LWC that passes it values the container cannot.

## Interactions

[Interactions](https://docs.avonnicomponents.com/dynamic-components/component-builder/interactions.md) define what happens when users interact with the LWC Container. Configure them from the **Interactions** tab of the **Edit Lwc Container** panel.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FM8lRVAtrRxrsZRSkMCf0%2Flwc-container-custom-interactions.png?alt=media" alt="The Interactions tab of the LWC Container with one Custom Interactions item named requestreview running Show Toast" width="320"><figcaption><p>One Custom Interactions item per event the LWC dispatches.</p></figcaption></figure>

### Custom Interactions

Runs interactions when the LWC dispatches a `CustomEvent`. Add one item per event: **Event Name** is the event's name, exactly as the LWC dispatches it (`requestreview`, `showtoast`), and **Type** is the interaction to run, such as **Show Toast**, **Open Flow Dialog** or **Refresh Query**.

Only the event's name reaches the container. Data the LWC puts in the event's `detail` does not, so an interaction reads its values from the page instead, for example `{!AccountsTable.firstSelectedRowSObject.Id}`. Custom Interactions run in Preview and on the published page, never on the builder canvas.

[React to an LWC Event](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/lwc-container/react-to-an-lwc-event.md) builds one from start to finish.

## Styling

Configure the LWC Container's frame from the **Style** tab of the **Edit Lwc Container** panel. The LWC's own CSS controls what is inside it.

{% tabs %}
{% tab title="Margin" %}
The space outside the container.

* **Top / Right / Bottom / Left:** the space on each side.
  {% endtab %}

{% tab title="Padding" %}
The space between the container's edge and the LWC.

* **Top / Right / Bottom / Left:** the inner space on each side.
  {% endtab %}

{% tab title="Size" %}
The container's dimensions.

* **Width / Height:** the container's width and height.
* **Overflow:** what happens to content larger than the container.
* **Min Width / Max Width / Min Height / Max height** (advanced): bounds on the size.
* **Overflow X / Overflow Y** (advanced): overflow on one axis only.
  {% endtab %}
  {% endtabs %}

## Troubleshooting Common Issues

* **The container shows "Errors while loading LWC component".** The name in **LWC Name** does not match a component the container can load. Check the namespace and the spelling (`c/accountSnapshot`, not `accountSnapshot` or `c-account-snapshot`), and that the component is deployed with `isExposed` set to `true`.
* **The LWC shows but a value is empty.** The **Name** in **LWC Attributes** must match the `@api` property exactly, case included. For a Data Table value, check that a row is selected: the **First Selected Row sObject** stays empty until the user selects one.
* **Nothing happens when the LWC fires its event.** The **Event Name** differs from the name the LWC dispatches (it is case-sensitive), or you are testing on the canvas, where Custom Interactions never run. Test in Preview.
* **The LWC behaves differently on the canvas.** The builder sets `isBuilder` (or the name in **Is Builder Attribute Name**) to `true`. An LWC that shows a placeholder on that flag shows its real content only in Preview and on the page.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avonnicomponents.com/dynamic-components/components/lwc-container.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
