Aspect Ratio Box is a lightweight, zero-JavaScript Reactive Web Block for OutSystems that maintains a consistent aspect ratio for any content placed inside it. Built entirely with CSS using the classic padding-bottom percentage trick, it works reliably across all browsers and devices without any external dependencies.
Simply configure the ratio width and height values and drop any content — images, videos, iframes, cards, or custom widgets — inside the block's content placeholder. The box will always maintain the correct proportions regardless of screen size.
The component uses the padding-bottom percentage trick — a well-known CSS technique where padding-bottom as a percentage is always calculated relative to the element's width, not its height. This creates a box with a mathematically correct height based on the ratio:
padding-bottom
PaddingBottom = (RatioHeight / RatioWidth) * 100
Examples:
Content is then placed inside an absolutely positioned inner container that fills 100% width and height of the outer box.
Ctrl+Q
AspectRatioLib
AspectRatioBox
AspectRatioConfig
Config
Create a Local Variable on your screen:
BoxConfig
In On Initialize set your values:
BoxConfig.RatioWidth = 16 BoxConfig.RatioHeight = 9 BoxConfig.Width = 640 BoxConfig.BackgroundColor = "#000000" BoxConfig.OverflowContent = "hidden" BoxConfig.BorderRadius = 8
Set the block's Config = BoxConfig
Config = BoxConfig
Click the Content placeholder inside the block and add your widgets:
Ctrl+P
Content
Drop any widget or content inside this placeholder. The content will fill 100% width and height of the aspect ratio box.
RatioWidth
16
RatioHeight
9
Width
400
BackgroundColor
"#000000"
OverflowContent
"hidden"
BorderRadius
0
hidden
visible
scroll
Perfect for video embeds that maintain widescreen proportions:
BoxConfig.RatioWidth = 16 BoxConfig.RatioHeight = 9 BoxConfig.Width = 640 BoxConfig.BackgroundColor = "#000000" BoxConfig.OverflowContent = "hidden" BoxConfig.BorderRadius = 8 AspectRatioBox (Config = BoxConfig) └── Content Placeholder: └── Iframe URL: "https://www.youtube.com/embed/VIDEO_ID" Width: 100% Height: 100% Border: 0
Result: A 640×360px video embed that always stays 16:9.
Great for product images or photo galleries:
BoxConfig.RatioWidth = 4 BoxConfig.RatioHeight = 3 BoxConfig.Width = 400 BoxConfig.BackgroundColor = "#f5f5f5" BoxConfig.OverflowContent = "hidden" BoxConfig.BorderRadius = 12 AspectRatioBox (Config = BoxConfig) └── Content Placeholder: └── Image Widget URL: YourImageURL Width: 100% Height: 100% Style: object-fit: cover
Result: A 400×300px image that is always perfectly 4:3.
Perfect for profile pictures, product thumbnails or square cards:
BoxConfig.RatioWidth = 1 BoxConfig.RatioHeight = 1 BoxConfig.Width = 200 BoxConfig.BackgroundColor = "#ffffff" BoxConfig.OverflowContent = "hidden" BoxConfig.BorderRadius = 100 AspectRatioBox (Config = BoxConfig) └── Content Placeholder: └── Image Widget (profile picture) Width: 100% Height: 100% Style: object-fit: cover
Result: A perfect 200×200px circle profile picture.
For wide hero banners or cinematic image displays:
BoxConfig.RatioWidth = 21 BoxConfig.RatioHeight = 9 BoxConfig.Width = 800 BoxConfig.BackgroundColor = "#1a1a1a" BoxConfig.OverflowContent = "hidden" BoxConfig.BorderRadius = 0
Result: An 800×343px cinematic banner.
For showing mobile app screenshots or portrait content:
BoxConfig.RatioWidth = 9 BoxConfig.RatioHeight = 16 BoxConfig.Width = 280 BoxConfig.BackgroundColor = "#f0f0f0" BoxConfig.OverflowContent = "hidden" BoxConfig.BorderRadius = 24
Result: A 280×498px portrait box — perfect mobile screen mockup.
Use in a list to ensure all cards maintain consistent proportions:
List Widget (Source: ProductList) └── List Item: └── AspectRatioBox Config: RatioWidth = 4 RatioHeight = 3 Width = 300 BorderRadius = 8 Content Placeholder: └── Image: Product.ImageURL
Result: All product cards maintain the same 4:3 ratio regardless of image dimensions.
Cause: Content widget does not have 100% width and height.
Fix:Set Width and Height to 100% on your content widget:
Image widget: Width: 100% Height: 100% Style: object-fit: cover
For containers, add inline style:
width: 100%; height: 100%;
Cause: RatioWidth or RatioHeight values are zero or not set.
Fix:Always initialize both values in On Initialize:
BoxConfig.RatioWidth = 16 ← Never set to 0 BoxConfig.RatioHeight = 9 ← Never set to 0
Setting either to 0 causes a division by zero and breaks the height calculation.
Cause: OverflowContent is set to visible.
Fix:Set OverflowContent = "hidden" to clip content within the box boundaries:
OverflowContent = "hidden"
BoxConfig.OverflowContent = "hidden"
Cause: Fixed pixel width exceeds mobile screen width.
Fix:The component's CSS already handles this with:
@media (max-width: 480px) { .ar-outer-box { width: 100% !important; } }
On mobile the box automatically fills the full screen width while maintaining its aspect ratio.
Cause: Image is forced to fill the box without maintaining its own proportions.
Fix:Add object-fit: cover to the image widget's style:
object-fit: cover
object-fit: cover; width: 100%; height: 100%;
This crops the image to fill the box while preserving its aspect ratio.
Cause: Content overflows outside the border radius.
Fix:Make sure OverflowContent = "hidden" — this clips the content to the rounded corners:
BoxConfig.OverflowContent = "hidden" BoxConfig.BorderRadius = 12
Cause: The iframe src URL may not allow embedding.
src
Fix:
width: 100%
height: 100%
border: 0
https://www.youtube.com/embed/VIDEO_ID
Not the regular watch URL.
Documentation Version: 1.0.0Component Version: 1.0.0Last Updated: 2026Author: — (your name here)