# Image Frame URL: /react/components/image-frame Source: https://github.com/daangn/seed-design/blob/dev/docs/content/react/components/image-frame.mdx A component for displaying images uploaded by users. 사용 가능 버전: @seed-design/react@1.2.0, @seed-design/css@1.2.0 ## Preview ```tsx import { ImageFrame } from "@seed-design/react"; import { ContentPlaceholder } from "seed-design/ui/content-placeholder"; export default function ImageFramePreview() { return ( } /> ); } ``` ## Usage ```tsx import { ImageFrame } from "@seed-design/react"; import { ContentPlaceholder } from "seed-design/ui/content-placeholder"; ``` ```tsx } /> ``` ## Props ## Examples ### Ratio You can specify various aspect ratios. `1` is square, `4/3` is a typical photo ratio, and `16/9` is a widescreen ratio. ```tsx import { ImageFrame, Flex, VStack, Text } from "@seed-design/react"; import { ContentPlaceholder } from "seed-design/ui/content-placeholder"; export default function ImageFrameRatio() { return ( } /> 1:1 } /> 4:3 } /> 16:9 ); } ``` ### Border Radius You can apply a corner rounding style using the `borderRadius` prop. The default is `"r2"`. ```tsx import { ImageFrame, Flex, VStack, Text } from "@seed-design/react"; import { ContentPlaceholder } from "seed-design/ui/content-placeholder"; export default function ImageFrameBorderRadius() { return ( } /> 20 / r1 (4px) } /> 24 / r1 (4px) } /> 36 / r1_5 (6px) } /> 42 / r1_5 (6px) } /> 48 / r1_5 (6px) } /> 64+ / r2 (8px) ); } ``` ### Stroke You can apply a border style using the `stroke` prop. ```tsx import { ImageFrame, Flex, VStack, Text } from "@seed-design/react"; import { ContentPlaceholder } from "seed-design/ui/content-placeholder"; export default function ImageFrameStroke() { return ( } /> stroke=false } /> stroke=true ); } ``` ### Fallback Image You can specify an element to display when an image fails to load using the `fallback` prop. Typically, [ContentPlaceholder](/react/components/content-placeholder) is used. ```tsx import { ImageFrame, Flex } from "@seed-design/react"; import { ContentPlaceholder } from "seed-design/ui/content-placeholder"; export default function ImageFrameFallbackExample() { return ( } /> } /> } /> ); } ``` ### Overlay You can place overlay elements over the image using `ImageFrameFloater`. Various overlay components are provided, such as `ImageFrameBadge`, `ImageFrameIcon`, `ImageFrameIndicator`, and `ImageFrameReactionButton`. ```tsx import { IconCarrotFill } from "@karrotmarket/react-monochrome-icon"; import { ImageFrame, ImageFrameFloater, ImageFrameBadge, ImageFrameIcon, ImageFrameIndicator, ImageFrameReactionButton, Flex, VStack, Text, } from "@seed-design/react"; import { ContentPlaceholder } from "seed-design/ui/content-placeholder"; import { useState } from "react"; export default function ImageFrameOverlayExample() { const [liked, setLiked] = useState(false); return ( } > NEW ImageFrameBadge } > } /> ImageFrameIcon } > +9 ImageFrameIndicator } > ImageFrameReactionButton ); } ``` #### Multiple Overlays You can place overlays at multiple locations simultaneously. ```tsx import { ImageFrame, ImageFrameFloater, ImageFrameBadge, ImageFrameReactionButton, } from "@seed-design/react"; import { ContentPlaceholder } from "seed-design/ui/content-placeholder"; import { useState } from "react"; export default function ImageFrameOverlayMultipleExample() { const [liked, setLiked] = useState(false); return ( } > NEW ); } ``` #### Custom Overlay `ImageFrameFloater` can accept any React element as children. In addition to predefined overlay components, you can place custom UI. ```tsx import { ImageFrame, ImageFrameFloater } from "@seed-design/react"; import { ContentPlaceholder } from "seed-design/ui/content-placeholder"; export default function ImageFrameOverlayCustomExample() { return ( } >
Custom Element
); } ``` #### Offset You can adjust the overlay margin using the `offsetX` and `offsetY` props. The default is `6px`. ```tsx import { ImageFrame, ImageFrameFloater, ImageFrameIndicator } from "@seed-design/react"; import { ContentPlaceholder } from "seed-design/ui/content-placeholder"; export default function ImageFrameOverlayInsetExample() { return (
} > default } > offset=0 } > offset=12
); } ```