> For the complete documentation index, see [llms.txt](https://dev.ubidots.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.ubidots.com/dashboards-and-widgets/custom-metric/layout-and-css.md).

# Layout and CSS

Make a Custom Metric widget fill its iframe and adapt to any size — full-bleed style.css reset, fluid units and responsive charts

The widget renders inside an iframe whose size the dashboard controls and changes live. The widget should fill 100% of the iframe and adapt fluidly to any size, from a small card to a large panel.

## `style.css`: start with a full-bleed reset

```css
html, body, #root { height: 100%; width: 100%; margin: 0; box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }
body { overflow: hidden; background: transparent; }
```

The file must be named exactly `style.css` and imported from your component (`import './style.css'`).

## Guidelines

* Give the top-level component `width: 100%; height: 100%`, for example a flex column or row, so it always fills the iframe. Don't use a fixed-size box centered in empty space.
* Use fluid units for the overall layout: `%`, `flex`, grid `minmax()`, `clamp()`, `vmin` / `vmax` / `cqi`. Keep fixed `px` for small details such as borders, gaps and icons.
* Size charts and canvases to their container (`width` / `height` 100%, or a `ResizeObserver`), never to a hard-coded px size.
* Keep `body { background: transparent }` so the widget blends into the dashboard.


---

# 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://dev.ubidots.com/dashboards-and-widgets/custom-metric/layout-and-css.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.
