Aspect Ratio
가로(width)가 정해지면 비율에 따라 세로(height)가 자동으로 결정되는 레이아웃 컨테이너입니다.
import { AspectRatio, Text, VStack } from "@seed-design/react";
export default function AspectRatioPreview() {
return (
<VStack gap="x4">
<AspectRatio ratio={4 / 3} width="160px" bg="palette.gray100">
<Text color="palette.gray700">4 / 3</Text>
</AspectRatio>
<AspectRatio ratio={1} width="160px" bg="palette.gray100">
<Text color="palette.gray700">1:1</Text>
</AspectRatio>
<AspectRatio ratio={16 / 9} width="160px" bg="palette.gray100">
<Text color="palette.gray700">16 / 9</Text>
</AspectRatio>
</VStack>
);
}Usage
import { AspectRatio } from "@seed-design/react";<AspectRatio ratio={16 / 9}>
<img src="..." alt="..." />
</AspectRatio>Props
Prop
Type
as?React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefinedasChild?boolean | undefinedbackground?(string & {}) | ScopedColorPalette | ScopedColorBg | ScopedColorBanner | undefinedbackgroundGradient?"fadeLayerFloating" | "fadeLayerDefault" | "glowMagic" | "glowMagicPressed" | "highlightMagic" | "highlightMagicPressed" | "shimmerMagic" | "shimmerNeutral" | undefinedcolor?(string & {}) | ScopedColorFg | ScopedColorPalette | undefinedborderColor?(string & {}) | ScopedColorPalette | ScopedColorStroke | undefinedborderWidth?0 | 1 | (string & {}) | undefinedborderTopWidth?0 | 1 | (string & {}) | undefinedborderRightWidth?0 | 1 | (string & {}) | undefinedborderBottomWidth?0 | 1 | (string & {}) | undefinedborderLeftWidth?0 | 1 | (string & {}) | undefinedborderRadius?0 | (string & {}) | "full" | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | undefinedborderTopLeftRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderTopRightRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderBottomRightRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderBottomLeftRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedboxShadow?(string & {}) | "s1" | "s2" | "s3" | undefinedwidth?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedminWidth?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedmaxWidth?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedheight?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedminHeight?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedmaxHeight?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedtop?0 | (string & {}) | undefinedleft?0 | (string & {}) | undefinedright?0 | (string & {}) | undefinedbottom?0 | (string & {}) | undefinedpadding?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedpaddingX?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedpaddingY?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedpaddingTop?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | "safeArea" | undefinedpaddingRight?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedpaddingBottom?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | "safeArea" | undefinedpaddingLeft?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefineddisplay?"none" | "block" | "flex" | "inline-flex" | "inline" | "inline-block" | "inlineFlex" | "inlineBlock" | undefinedzIndex?number | (string & {}) | undefinedflexDirection?"row" | "column" | "row-reverse" | "column-reverse" | "rowReverse" | "columnReverse" | undefinedjustifyContent?"flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "flexStart" | "flexEnd" | "spaceBetween" | "spaceAround" | undefinedalignItems?"flex-start" | "flex-end" | "center" | "flexStart" | "flexEnd" | "stretch" | undefinedalignContent?"flex-start" | "flex-end" | "center" | "flexStart" | "flexEnd" | "stretch" | undefinedalignSelf?"flex-start" | "flex-end" | "center" | "flexStart" | "flexEnd" | "stretch" | undefinedgap?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedgridColumn?string | undefinedgridRow?string | undefinedunstable_transform?string | undefined_active?{ bg?: ScopedColorBg | ScopedColorPalette | (string & {}); background?: ScopedColorBg | ScopedColorPalette | (string & {}); } | undefinedExamples
Ratio
다양한 비율을 지정할 수 있습니다. 1은 정사각형, 4/3은 일반적인 사진 비율, 16/9는 와이드스크린 비율입니다.
import { AspectRatio, Box, HStack } from "@seed-design/react";
export default function AspectRatioRatio() {
return (
<HStack gap="x4">
<Box width="150px">
<AspectRatio ratio={1}>
<img src="https://picsum.photos/seed/square/400/400" alt="1:1 Square" />
</AspectRatio>
</Box>
<Box width="150px">
<AspectRatio ratio={4 / 3}>
<img src="https://picsum.photos/seed/4-3/400/300" alt="4:3" />
</AspectRatio>
</Box>
<Box width="150px">
<AspectRatio ratio={16 / 9}>
<img src="https://picsum.photos/seed/16-9/400/225" alt="16:9" />
</AspectRatio>
</Box>
</HStack>
);
}Last updated on