Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tailwindcss/aspect-ratio

Package Overview
Dependencies
Maintainers
5
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tailwindcss/aspect-ratio

A plugin that provides a composable API for giving elements a fixed aspect ratio.

  • 0.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created

What is @tailwindcss/aspect-ratio?

@tailwindcss/aspect-ratio is a Tailwind CSS plugin that provides utilities for controlling the aspect ratio of an element. This is particularly useful for embedding responsive videos, images, or any other content that needs to maintain a specific aspect ratio.

What are @tailwindcss/aspect-ratio's main functionalities?

Aspect Ratio Utilities

This feature allows you to set a specific aspect ratio for an element. In this example, the aspect ratio is set to 16:9, which is commonly used for videos.

<div class="aspect-w-16 aspect-h-9">
  <iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ" title="YouTube video" allowfullscreen></iframe>
</div>

Custom Aspect Ratios

You can also set custom aspect ratios using the aspect-w-{n} and aspect-h-{n} classes. In this example, the aspect ratio is set to 4:3, which is often used for photographs.

<div class="aspect-w-4 aspect-h-3">
  <img src="path/to/image.jpg" alt="Example Image">
</div>

Square Aspect Ratio

For elements that need to maintain a square aspect ratio, you can use the aspect-w-1 and aspect-h-1 classes. This ensures the element remains a perfect square.

<div class="aspect-w-1 aspect-h-1">
  <img src="path/to/square-image.jpg" alt="Square Image">
</div>

Other packages similar to @tailwindcss/aspect-ratio

FAQs

Package last updated on 02 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc