Getting startedComponentsDesign tokensThemingTheme synthesizerFrameworksAccessibilityUtilitiesServer renderingBrowser supportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting startedFrameworksServer renderingDesign tokensThemingTheme synthesizerTypographyUtilitiesAll componentsAccessibilityBrowser supportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Aspect Ratio

A box that holds its content to a fixed width-to-height ratio.

ComponentsAspect Ratio
contentstatic
<arc-aspect-ratio>

Overview

AspectRatio keeps its content at a fixed width-to-height ratio with the CSS `aspect-ratio` property. Pass a `W/H` string like `"16/9"`, `"4/3"` or `"1/1"`. The container is as wide as its parent and takes its height from the ratio, so it reserves the space for an image or video before the media loads and the page doesn't shift (CLS). Every slotted child is sized to fill the box. Images and videos get `object-fit: cover`, so they're cropped, never letterboxed or stretched. Text that doesn't fit is clipped, with no scrolling.

Guidelines

Do

  • Wrap images and videos in it to stop the page shifting as they load
  • Match the ratio to the media: `16/9` for video, `4/3` for photos, `1/1` for avatars or thumbnails
  • Put it in a grid or flex container that sets its width
  • Use it with lazy-loaded images, since the space is reserved before the image arrives

Don't

  • Don't use it when the content has its own fixed dimensions and layout shift isn't a problem
  • Don't put a lot of text in it
  • Don't set a fixed height on the same element. The two conflict

Features

  • Decimal ratios work, such as `2.35/1` for cinematic widescreen
  • An unparseable ratio, or one with a zero on either side, falls back to `16/9`
  • Corners are rounded with `--radius-md`

Preview

16 / 9

Usage

<arc-aspect-ratio ratio="16/9">
  <img src="/hero.jpg" alt="Hero banner" />
</arc-aspect-ratio>

<!-- Square thumbnail -->
<arc-aspect-ratio ratio="1/1">
  <img src="/avatar.jpg" alt="User avatar" />
</arc-aspect-ratio>

API

DEFAULT_RATIOstring'16/9'
The documented default, and what anything unusable normalises to.
ratiostring'16/9'
Aspect ratio as a W/H string. Supports integers and decimals. An unparseable value, or one with a zero on either side, is normalised **on the property** to 16/9, so reading ratio back always gives the ratio the component is actually using.

See also