Aspect Ratio
Aspect Ratio is part of the Layout and content group. Fixed-ratio frame for media and previews.
Installation
Section titled “Installation”npx bambiui add aspect-ratio --framework reactnpx bambiui add aspect-ratio --framework solidnpx bambiui add aspect-ratio --framework sveltenpx bambiui add aspect-ratio --framework vueimport { AspectRatio, AspectRatioContent } from "@/components/ui/aspect-ratio";
export function Example() { return <AspectRatio />;}import { AspectRatio, AspectRatioContent } from "~/components/ui/aspect-ratio";
export function Example() { return <AspectRatio />;}<script lang="ts"> import { AspectRatio, AspectRatioContent } from "$lib/components/ui/aspect-ratio";</script>
<AspectRatio /><script setup lang="ts">import { AspectRatio, AspectRatioContent } from "@/components/ui/aspect-ratio";</script>
<template> <AspectRatio /></template>Preview
Section titled “Preview”
Aspect Ratio preview should be verified in the target framework after copying the component source. Interactive behavior comes from generated public artifacts, not docs-only mock behavior.
Behavior
Section titled “Behavior”Use for images, videos, and cards that need stable dimensions.
Generated output uses serializable data-* attributes for state and styling. Controlled components fire bambi:<event-name> events and expect application state to update externally; uncontrolled components manage local source state and still fire events.
Accessibility
Section titled “Accessibility”Use semantic labels, visible focus states, and keyboard interaction patterns appropriate for Aspect Ratio. Do not hide required instructions in transient UI. Verify focus movement and disabled states in the installed framework output.
Exports
Section titled “Exports”AspectRatio, AspectRatioContentTokens
Section titled “Tokens”Customize tokens after installing and previewing the component. Relevant tokens include:
--bambi-background--bambi-border--bambi-radius-md