Aspect Ratio
Generated from public Vue/TypeScript exports by
pnpm docs:generate. Edit source comments and stories to update this reference. Types describe the declared API; browser/device constraints are covered in the guides. This catalog reflects source commitfc6bfb108634735f1657e533206c3f8702ad357d; match your installed package and typed manifest before using an export. Source review does not establish registry-release availability.
AspectRatio
import { AspectRatio } from '@gxp-dev/app-ui'
Props
| Name | Type | Required / default | Description |
|---|---|---|---|
ratio | number | undefined | — | The desired ratio. Eg: 16/9 |
asChild | boolean | undefined | — | Change the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. |
as | AsTag | Component | undefined | — | The element or component this component should render as. Can be overwritten by asChild. |
Slots
| Name | Type | Required / default | Description |
|---|---|---|---|
default | {} | — | — |
Examples
These are authored Storybook excerpts, not complete standalone modules. Relative imports refer to the story file; in an app import public components from @gxp-dev/app-ui. Default meta arguments are applied before each story.
Default
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { AspectRatio } from '.'
const defaultArgs = {
ratio: 16 / 9,
}
{
render: (args) => ({
components: { AspectRatio },
setup() {
return { args }
},
template: `
<div class="w-[450px]">
<AspectRatio v-bind="args">
<div class="flex h-full w-full items-center justify-center rounded-md bg-muted">
<span class="text-sm text-muted-foreground">16:9</span>
</div>
</AspectRatio>
</div>
`,
}),
}
Square
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { AspectRatio } from '.'
const defaultArgs = {
ratio: 16 / 9,
}
{
name: 'Square (1:1)',
render: () => ({
components: { AspectRatio },
template: `
<div class="w-[300px]">
<AspectRatio :ratio="1">
<div class="flex h-full w-full items-center justify-center rounded-md bg-muted">
<span class="text-sm text-muted-foreground">1:1</span>
</div>
</AspectRatio>
</div>
`,
}),
}