Skip to content

Aspect Ratio

@astryxdesign/core v0.7.1 · AspectRatio

Aspect Ratio Props ​

NameTypeDefaultDescription
rationumber-Width divided by height. 16 / 9 is a widescreen frame. Written to --astryx-aspect-ratio, not as an inline aspect-ratio.
shape'rectangle' | 'ellipse''rectangle'Container shape. Both shapes follow ratio. ellipse with ratio 1 is a circle.
fit'cover' | 'contain' | 'center'-How the child fills the box. cover crops, contain letterboxes, center keeps the natural size. Omit it and the child sizes itself.

Slots ​

NameDescription
defaultThe content inside the ratio box. Pass one child when fit is set.

CSS variables ​

NameDescription
--astryx-aspect-ratioThe ratio. A stylesheet can override the variable or aspect-ratio itself.

Native attributes ​

AspectRatio renders a <div>.

The following go to that element:

  • HTML attributes.
  • aria-* attributes.
  • data-* attributes.
  • class.
  • style.

class is merged. The root also sets data-shape.