import { Image } from "@vortexlabs/vortex-native";
<Image
src="https://cdn.vortex.design/docs/components/image/sydney.webp"
alt="Sydney Harbour"
width={240}
height={140}
objectFit="cover"
borderRadius="md"
bordered={false}
/>Features
- Displays network images and bundled assets.
- Supports responsive dimensions and aspect ratios.
- Controls cropping, rounded corners, and borders.
- Shows a backup image or custom content when loading fails.
Size and Aspect Ratio
Give a network image a width and either a height or an aspect ratio. Here, aspectRatio={4 / 3} keeps the photo in proportion as its width changes.
import { Image } from "@vortexlabs/vortex-native";
const photo = "https://cdn.vortex.design/docs/components/image/sydney.webp";
<Image src={photo} alt="Sydney Harbour" width={{ xs: 160, md: 280 }} aspectRatio={4 / 3} />Bundled images use their intrinsic dimensions. Pass the result of require() directly to src and set width to resize the image at its original aspect ratio.
<Image src={require("./assets/harbour.jpg")} alt="Sydney Harbour" width={160} />Object Fit
cover fills the frame and crops excess content. contain fits the entire picture inside the frame. scale-down also preserves the whole picture and keeps small images at their original size.
<Stack direction="row" gap={3} wrap>
{(["cover", "contain", "scale-down"] as const).map((fit) => (
<Stack key={fit} gap={1}>
<Image src={photo} alt="Sydney Harbour" width={96} height={96} objectFit={fit} bordered />
<Text>{fit}</Text>
</Stack>
))}
</Stack>Borders and Corners
borderRadius clips the image to a theme radius. Add bordered to draw a thin outline along that edge.
<Image src={photo} alt="Sydney Harbour" width={160} height={96} borderRadius="lg" bordered />Fallback
When src is empty or fails to load, pass a backup URL, render replacement content, or use fallback={true} to keep an empty frame. A backup image keeps the same size, fit, and accessible name.
<Stack direction="row" gap={3} wrap>
<Image src="" alt="Sydney Harbour" width={160} height={96} fallback={photo} />
<Image src="" alt="Project cover unavailable" width={160} height={96}
fallback={<Text>Cover unavailable</Text>} />
</Stack>Native Image Attributes
Pass React Native image options through imageAttributes. These options and the public onLoad and onError callbacks apply to the primary image. Use attributes for the outer view.
<Image
src={photo}
alt="Sydney Harbour"
width={240}
aspectRatio={4 / 3}
imageAttributes={{ resizeMethod: "resize" }}
attributes={{ testID: "harbour-photo" }}
/>Custom Rendering
Use renderImageSlot to supply a compatible image component. Forward the supplied source, styles, resize mode, and load handlers so the picture fills the frame and appears when loading completes.
import { Image } from "@vortexlabs/vortex-native";
import { Image as NativeImage } from "react-native";
<Image
src={photo}
alt="Sydney Harbour"
width={240}
aspectRatio={4 / 3}
renderImageSlot={(attributes) => <NativeImage {...attributes} />}
/>Accessibility
alt as its accessible name, including when fallback content appears.alt to an empty string for decorative images to hide them from screen readers.