AspectRatio
AspectRatio keeps its content at a fixed width-to-height ratio. Use it for images, video, embeds and maps. AspectRatio fills its parent width, so place it in a sized container.
Installation
Run npx nxds-cli@latest init first if nxds isn’t set up in your app yet. See Install.
Usage
Examples
Ratios
Compare square, 4:3 and 16:9 boxes side by side.
Props
AspectRatio
AspectRatio adds no props of its own; it accepts the props of the element or primitive it wraps.
AspectRatio keeps its content at a fixed width-to-height ratio. Use it for images, video, embeds and maps. AspectRatio fills its parent width, so place it in a sized container.
Installation
Install the following dependencies:
Copy and paste the following code into your project.
components/aspect-ratio/AspectRatio.vue components/aspect-ratio/index.ts Keep each file at the path shown above it.
Paths are relative to
packages/vue/src/. Keep the same folders under your@/root, and the imports between files work without edits.
Usage
Examples
Ratios
Compare square, 4:3 and 16:9 boxes side by side.
Props
AspectRatio
AspectRatio adds no props of its own; it accepts the props of the element or primitive it wraps.