Documentation
Layout
AspectRatio
Keeps media and embeds in a predictable ratio.
01
See it in context
Preview
16 / 9 media area
4 / 3 media area
02
Copy a working example
Usage
---
import {
AspectRatio,
Card
} from '@santi020k/lumen-astro'
---
<AspectRatio ratio="16 / 9">
<Card variant="muted">16 / 9 media area</Card>
</AspectRatio>
<AspectRatio ratio="4 / 3">
<Card variant="muted">4 / 3 media area</Card>
</AspectRatio>---
import {
AspectRatio,
Card
} from '@santi020k/lumen-astro'
---
<AspectRatio ratio="16 / 9">
<Card variant="muted">16 / 9 media area</Card>
</AspectRatio>
<AspectRatio ratio="4 / 3">
<Card variant="muted">4 / 3 media area</Card>
</AspectRatio>import { AspectRatio, Card } from '@santi020k/lumen-react'
export const Example = () => (
<>
<AspectRatio ratio="16 / 9">
<Card variant="muted">16 / 9 media area</Card>
</AspectRatio>
<AspectRatio ratio="4 / 3">
<Card variant="muted">4 / 3 media area</Card>
</AspectRatio>
</>
)import { AspectRatio, Card } from '@santi020k/lumen-react'
export const Example = () => (
<>
<AspectRatio ratio="16 / 9">
<Card variant="muted">16 / 9 media area</Card>
</AspectRatio>
<AspectRatio ratio="4 / 3">
<Card variant="muted">4 / 3 media area</Card>
</AspectRatio>
</>
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<lumen-aspect-ratio ratio="16 / 9">
<lumen-card variant="muted">16 / 9 media area</lumen-card>
</lumen-aspect-ratio>
<lumen-aspect-ratio ratio="4 / 3">
<lumen-card variant="muted">4 / 3 media area</lumen-card>
</lumen-aspect-ratio><script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<lumen-aspect-ratio ratio="16 / 9">
<lumen-card variant="muted">16 / 9 media area</lumen-card>
</lumen-aspect-ratio>
<lumen-aspect-ratio ratio="4 / 3">
<lumen-card variant="muted">4 / 3 media area</lumen-card>
</lumen-aspect-ratio>03
Choose your target
Add this component
Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.
pnpm add @santi020k/lumen-astropnpm add @santi020k/lumen-astrolumen add AspectRatiolumen add AspectRatiopnpm add @santi020k/lumen-reactpnpm add @santi020k/lumen-reactlumen add AspectRatio --target reactlumen add AspectRatio --target reactpnpm add @santi020k/lumen-elementspnpm add @santi020k/lumen-elementslumen add AspectRatio --target elementslumen add AspectRatio --target elementsAPI reference
Lumen-specific props and runtime attributes for the Astro primitive. React props follow the same names; Elements use equivalent kebab-case attributes where custom elements expose them.
| Attribute | Values | Default | Description |
|---|---|---|---|
| ratio | number | string | "16 / 9" | Sets the preferred CSS aspect-ratio value; invalid values fall back to 16 / 9. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML attributes | - | Forwards standard attributes to the root element unless the component consumes them. |