{"id":13480350,"url":"https://github.com/webdna/tailwindcss-aspect-ratio","last_synced_at":"2025-04-04T22:06:19.633Z","repository":{"id":30786598,"uuid":"125986414","full_name":"webdna/tailwindcss-aspect-ratio","owner":"webdna","description":"Aspect Ratio Plugin for tailwindcss framework","archived":false,"fork":false,"pushed_at":"2023-01-06T02:00:38.000Z","size":1756,"stargazers_count":247,"open_issues_count":18,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T21:05:02.448Z","etag":null,"topics":["aspect-ratio","plugin","tailwind","tailwindcss","tailwindcss-plugin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webdna.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-20T08:42:23.000Z","updated_at":"2024-08-26T07:16:22.000Z","dependencies_parsed_at":"2023-01-14T17:40:39.202Z","dependency_job_id":null,"html_url":"https://github.com/webdna/tailwindcss-aspect-ratio","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webdna%2Ftailwindcss-aspect-ratio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webdna%2Ftailwindcss-aspect-ratio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webdna%2Ftailwindcss-aspect-ratio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webdna%2Ftailwindcss-aspect-ratio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webdna","download_url":"https://codeload.github.com/webdna/tailwindcss-aspect-ratio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256112,"owners_count":20909240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspect-ratio","plugin","tailwind","tailwindcss","tailwindcss-plugin"],"created_at":"2024-07-31T17:00:37.812Z","updated_at":"2025-04-04T22:06:19.612Z","avatar_url":"https://github.com/webdna.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":[],"readme":"# ⛔️ DEPRECATED\n\nThis plugin was created before the [`aspect-ratio`](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) property was supported by any browser. You should now use the official [`@tailwindcss/aspect-ratio`](https://github.com/tailwindlabs/tailwindcss-aspect-ratio) plugin.\n\n# Aspect Ratio Plugin for Tailwind CSS\n\n## Requirements\n\nThis plugin requires Tailwind CSS 1.2 or later. If your project uses an older version of Tailwind, you should install the latest 2.x version of this plugin (`npm install tailwindcss-aspect-ratio@2.x`).\n\n## Installation\n\n```bash\nnpm install tailwindcss-aspect-ratio\n```\n\n## Usage\n\nThis plugin uses the `aspectRatio` key in your Tailwind config’s `theme` and `variants` objects to generate aspect ratio utilities. Here is an example:\n\n```js\n// tailwind.config.js\nmodule.exports = {\n  theme: {\n    aspectRatio: { // defaults to {}\n      'none': 0,\n      'square': [1, 1], // or 1 / 1, or simply 1\n      '16/9': [16, 9],  // or 16 / 9\n      '4/3': [4, 3],    // or 4 / 3\n      '21/9': [21, 9],  // or 21 / 9\n    },\n  },\n  variants: {\n    aspectRatio: ['responsive'], // defaults to ['responsive']\n  },\n  plugins: [\n    require('tailwindcss-aspect-ratio'),\n  ],\n};\n```\n\nThe `aspectRatio` theme object is a dictionary where the key is the suffix of the class name and the value is an array of width and height or a number that represents a width / height ratio. The key doesn’t have to replicate the values, so if you prefer \"nice names\" you could have something like `'video': [16, 9]`.\n\nThe above configuration would create the following classes, as well as their responsive variants:\n\n```css\n.aspect-ratio-none {\n  padding-bottom: 0;\n}\n.aspect-ratio-square {\n  padding-bottom: 100%;\n}\n.aspect-ratio-16\\/9 {\n  padding-bottom: 56.25%;\n}\n.aspect-ratio-4\\/3 {\n  padding-bottom: 75%;\n}\n.aspect-ratio-21\\/9 {\n  padding-bottom: 42.86%;\n}\n```\n\nWhich you can then use in your HTML like this:\n\n```html\n\u003cdiv class=\"relative\"\u003e\n  \u003cdiv class=\"aspect-ratio-16/9\"\u003e\u003c/div\u003e\n  \u003cimg src=\"thumbnail.jpg\" class=\"absolute left-0 top-0 w-full h-full object-cover\"\u003e\n\u003c/div\u003e\n```\n\nOr inside a `flex` container to behave like a “minimum aspect ratio” (if the content overflows, the container will grow instead of forcing the aspect ratio):\n\n```html\n\u003cdiv class=\"flex bg-gray-300\"\u003e\n  \u003cdiv class=\"aspect-ratio-2/1\"\u003e\u003c/div\u003e\n  \u003cp\u003e\n    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sed dictum sem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas et lacus ut dolor rutrum dignissim.\n  \u003c/p\u003e\n\u003c/div\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebdna%2Ftailwindcss-aspect-ratio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebdna%2Ftailwindcss-aspect-ratio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebdna%2Ftailwindcss-aspect-ratio/lists"}