Aspect Ratio
Layout helper — locks child height to a fraction of its width.
ui layout
Preview
Installation
npx slintcn@latest add aspect-ratioUsage
import { AspectRatio } from "slintcn/components/aspect-ratio.slint";
AspectRatio {
ratio: 16 / 9;
Image { source: @image-url("hero.png"); image-fit: cover; }
}
Properties
ratio
in
float
Width-to-height ratio (e.g. 16/9 = 1.778, 1/1 = 1.0, 3/4 = 0.75).
API
Accessibility
focusablenoDependencies
theme only
Installed automatically as transitive dependencies of slintcn add aspect-ratio.