← Back to site

Using Images

The Img component displays optimized images with automatic responsive sizing and an optional click-to-enlarge modal. Images must be local files in src/assets/.

Place images in the matching asset folder for your post type:

Post typeImage folder
Eventssrc/assets/events/
Projectssrc/assets/projects/

Then import the image using the @assets alias:

import { Accordion, Button, Callout, Carousel, Center, ImageGrid, Img, Instagram, Marquee, YouTube, SideBySide, Left, Right } from '@mdx';
import photo from '@assets/events/my-photo.jpg';

<Img src={photo} alt="Workshop participants" />
Example project image

Click the image above to see the full-size modal.

Controlling Width

Set width to any CSS value — percentages, pixels, etc:

<Img src={photo} alt="Small preview" width="50%" />
Half-width example

Disabling Click-to-Enlarge

For decorative images or icons where the modal doesn’t make sense:

<Img src={photo} alt="Decorative" enableClickToEnlarge={false} />

Required Fields

FieldTypeDescription
srcImageMetadataImported image file (e.g., import img from '@assets/...')
altstringDescription for accessibility

Optional Fields

FieldTypeDescription
widthstringCSS width, e.g. "50%", "400px" (default: "100%")
enableClickToEnlargebooleanShow full-size modal on click (default: true)
loadingenum"lazy" or "eager" — use eager for above-the-fold (default: "lazy")
fillbooleanStretch to fill parent container (default: false)
classstringExtra CSS classes, e.g. "rounded-full shadow-lg"