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
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, gridminmax(),clamp(),vmin/vmax/cqi. Keep fixedpxfor small details such as borders, gaps and icons.Size charts and canvases to their container (
width/height100%, or aResizeObserver), never to a hard-coded px size.Keep
body { background: transparent }so the widget blends into the dashboard.
Last updated
Was this helpful?