Back to library

Aspect ratio

Keep media at a consistent aspect ratio as its container resizes.

16 : 9

Recommended API

Property or elementTypeExample initial valueDescription
aspect-ratioCSS ratio16 / 9Reserve proportionate space for media as its width changes.

States

StateTriggerResult
resizedChange the available width.The height follows the same aspect ratio.

Svelte implementation guidance

Maintain a configurable width-to-height ratio as the container resizes.

Use semantic HTML and preserve keyboard access. Adapt the example to the project conventions.

CSS variables

VariableTypeDefaultDescription
--q-textcolor #28302aMain text and foreground color.
--q-mutedcolor #70776fColor for secondary text.
--q-font-sizelength 13pxBase size for the component text.
--q-accentcolor #344e41Accent for active controls, indicators and focus.
--q-surfacecolor #ffffffSurface for controls and cards.
--q-radiuslength 10pxBase corner radius.
--q-on-accentcolor #ffffffForeground on the accent background.