Image
A component for displaying images.
View in Storybook (opens in a new tab)
Installation
import { Image } from "@ginga-ui/core";Basic usage
A simple image example.
image.tsx
image.module.css
import { Image } from "@ginga-ui/core";
import styles from "./image.module.css";
export function BasicExample() {
return (
<Image
src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4"
alt="A beautiful mountain landscape"
className={styles.basicImage}
/>
);
}Avatar
An example of an avatar image.
image.tsx
image.module.css
import { Image } from "@ginga-ui/core";
import styles from "./image.module.css";
export function AvatarExample() {
return (
<div className={styles.avatars}>
<Image
src="https://images.unsplash.com/photo-1535713875002-d1d0cf377fde"
alt="User avatar"
variant="avatar"
className={styles.avatarSmall}
/>
<Image
src="https://images.unsplash.com/photo-1494790108377-be9c29b29330"
alt="User avatar"
variant="avatar"
className={styles.avatarMedium}
/>
<Image
src="https://images.unsplash.com/photo-1599566150163-29194dcaad36"
alt="User avatar"
variant="avatar"
className={styles.avatarLarge}
/>
</div>
);
}Sizes
Displays images in various sizes.
image.tsx
image.module.css
import { Image } from "@ginga-ui/core";
import styles from "./image.module.css";
export function SizesExample() {
return (
<div className={styles.sizes}>
<Image
src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4"
alt="Small size"
className={styles.smallImage}
/>
<Image
src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4"
alt="Medium size"
className={styles.mediumImage}
/>
</div>
);
}Rounded corners
Displays an image with rounded corners.
image.tsx
image.module.css
import { Image } from "@ginga-ui/core";
import styles from "./image.module.css";
export function RoundedExample() {
return (
<Image
src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4"
alt="Image with rounded corners"
className={styles.roundedImage}
/>
);
}Props
Image
| Name | Type | Default | Description |
|---|---|---|---|
alt | string | - | Required. Alternative text. Pass "" for decorative images. |
variant | "default" | "avatar" | "default" | "avatar" crops the image into a circle. |
render | (props) => ReactElement | - | Replaces the root element. Return an element that receives the given props, such as next/link. |
Also accepts the attributes of the HTML img (opens in a new tab) element.