> For the complete documentation index, see [llms.txt](https://cjays-organization.gitbook.io/nexora.ts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cjays-organization.gitbook.io/nexora.ts/message-ui/layout-container.md).

# LayoutContainerBuilder

Components V2 layout container — groups text, media, sections, and interactive components. Prefer this over classic embeds for new UIs.

**Package:** `@nexora.ts/core`\
**Factories:** `container()`, alias `MessageContainerBuilder`\
**Flag:** replies must use `IsComponentsV2` (`ctx.componentsV2` / `v2Message` set it for you)

> Named `LayoutContainerBuilder` so it does not clash with the DI `Container`.

## Quick example

```ts
import { container, text, separator, type CommandContext } from '@nexora.ts/core';

export async function welcome(ctx: CommandContext) {
  await ctx.componentsV2(
    container()
      .accent(0x5865f2)
      .add(
        text(`# Welcome, ${ctx.user.username}`),
        separator(),
        text('Thanks for joining the server.'),
      ),
  );
}
```

## Card preset

```ts
import { ComponentsV2, type CommandContext } from '@nexora.ts/core';

await ctx.reply(
  ComponentsV2.card({
    title: 'Ticket created',
    body: 'A moderator will reply soon.',
    accent: '#57F287',
  }).toJSON(),
);
```

## Richer layout

```ts
import {
  container,
  text,
  separator,
  section,
  thumbnail,
  gallery,
  ButtonBuilder,
  ActionRowBuilder,
  type CommandContext,
} from '@nexora.ts/core';

await ctx.componentsV2(
  container()
    .accent('#5865F2')
    .add(
      text('# Server status'),
      section('All systems operational').accessory(thumbnail(ctx.guild!.iconURL()!)),
      separator(),
      gallery('https://example.com/banner.png'),
      new ActionRowBuilder().add(
        new ButtonBuilder().customId('refresh').label('Refresh').primary(),
      ),
    ),
);
```

## Helpers

| Helper           | Type | Role                                |
| ---------------- | ---- | ----------------------------------- |
| `text(md)`       | 10   | Markdown text display               |
| `section(…)`     | 9    | Text + accessory (button/thumbnail) |
| `thumbnail(url)` | 11   | Small image accessory               |
| `gallery(…)`     | 12   | Media gallery                       |
| `file(name)`     | 13   | Attachment reference                |
| `separator()`    | 14   | Spacing / divider                   |
| `container(…)`   | 17   | Visual group + accent color         |
| `v2Message(…)`   | —    | `{ components, flags }` payload     |

**Limits:** Discord allows up to **40** components per message — builders can warn via `validate()`.

## Related

* [Components V2 guide](/nexora.ts/builders-and-ui/components-v2.md)
* [EmbedBuilder](/nexora.ts/message-ui/embed-builder.md) (classic alternative)
* [SlashCommand](/nexora.ts/framework/slash-command.md)


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cjays-organization.gitbook.io/nexora.ts/message-ui/layout-container.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
