1. Components
  2. aspect-ratio

Aspect Ratio

Utility component to maintain specific dimensions for images or videos.

Demo

Image by Johnnathan Tshibangu
<x-ui.aspect aspect="video">
    <img src="/images/img2.webp" class="w-full h-full object-cover rounded-lg" width="2400"
        alt="Image by Johnnathan Tshibangu" loading="lazy" decoding="async" fetchpriority="low">
</x-ui.aspect>

Installation

Shell
php artisan flexi:add aspect

Examples

Square

Image by Johnnathan Tshibangu
<x-ui.aspect aspect="square">
    <img src="/images/img2.webp" class="w-full h-full object-cover rounded-lg" width="2400"
        alt="Image by Johnnathan Tshibangu" loading="lazy" decoding="async" fetchpriority="low">
</x-ui.aspect>

Video

Image by Johnnathan Tshibangu
<x-ui.aspect aspect="video">
    <img src="/images/img2.webp" class="w-full h-full object-cover rounded-lg" width="2400"
        alt="Image by Johnnathan Tshibangu" loading="lazy" decoding="async" fetchpriority="low">
</x-ui.aspect>

Standard TV

Image by Johnnathan Tshibangu
<x-ui.aspect aspect="standard-tv">
    <img src="/images/img2.webp" class="w-full h-full object-cover rounded-lg" width="2400"
        alt="Image by Johnnathan Tshibangu" loading="lazy" decoding="async" fetchpriority="low">
</x-ui.aspect>

35mm film

Image by Johnnathan Tshibangu
<x-ui.aspect aspect="35mm-film">
    <img src="/images/img2.webp" class="w-full h-full object-cover rounded-lg" width="2400"
        alt="Image by Johnnathan Tshibangu" loading="lazy" decoding="async" fetchpriority="low">
</x-ui.aspect>

Ultra wide

Image by Johnnathan Tshibangu
<x-ui.aspect aspect="ultrawide">
    <img src="/images/img2.webp" class="w-full h-full object-cover rounded-lg" width="2400"
        alt="Image by Johnnathan Tshibangu" loading="lazy" decoding="async" fetchpriority="low">
</x-ui.aspect>

References

Props

The aspect ratio component accepts the following props. The aspect prop is required.

Prop Type Default Description
aspect string 'video'
The container ratio. Predefined values include video , square , 35mm-film , standard-tv , and ultrawide .
class string ''
Additional classes for the ratio container.