> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stac.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# ColoredBox

> Documentation for ColoredBox

export const PLAYGROUND_BASE_URL = "https://playground.stac.dev/";

export const coloredBoxPreviewJson = {
  "type": "coloredBox",
  "color": "#FF0000",
  "child": {
    "type": "text",
    "data": "Hello, World!"
  }
};
export const coloredBoxPreviewSrc = `${PLAYGROUND_BASE_URL}/embed`;

The Stac Colored Box allows you to build a Flutter colored box widget using JSON.
To know more about the colored box widget in Flutter, refer to the [official documentation](https://api.flutter.dev/flutter/widgets/ColoredBox-class.html).

## Properties

| Property | Type         | Description                                   |
| -------- | ------------ | --------------------------------------------- |
| color    | `StacColor`  | The color to paint the background of the box. |
| child    | `StacWidget` | The widget to display inside the colored box. |

## Example

<Tabs sync={false}>
  <Tab title="Dart">
    ```dart theme={null}
    StacColoredBox(
      color: StacColors.red,
      child: StacText(data: 'Hello, World!'),
    )
    ```
  </Tab>

  <Tab title="JSON">
    ```json theme={null}
    {
      "type": "coloredBox",
      "color": "#FF0000",
      "child": {
        "type": "text",
        "data": "Hello, World!"
      }
    }
    ```
  </Tab>

  <Tab title="Preview">
    <Frame>
      <iframe
        id="stac"
        src={coloredBoxPreviewSrc}
        title="Stac Playground"
        className="w-full rounded-xl border-0"
        style={{ height: "640px" }}
        loading="lazy"
        onLoad={(event) => {
      const iframe = event.currentTarget;
      const targetOrigin = PLAYGROUND_BASE_URL;
      const message = {
        type: "stac-preview-json",
        payload: coloredBoxPreviewJson
      };

      let attempts = 0;
      const maxAttempts = 12;
      const interval = setInterval(() => {
        iframe.contentWindow?.postMessage(message, targetOrigin);
        attempts += 1;

        if (attempts >= maxAttempts) {
          clearInterval(interval);
        }
      }, 250);
    }}
      />
    </Frame>
  </Tab>
</Tabs>
