Saltar al contenido principal

Image

peligro

This SDK is a Work In Progress! All features are subject to change.

We support multiple UI components built in JSX, some of which support nesting, to enable the creation of rich user interfaces. The UI components are assigned to slots by sending the ui:slot:set event.

Used to display images. It supports properties such as src, alt, width, height, and responsive sources for different screen sizes.

Field

Usage

Example
import { Image } from "@tiendanube/nube-sdk-jsx";

function MyComponent() {
return (
<Image
src="https://app-insti-cdn.nuvemshop.com.br/site/dist/images/widgets/closing-cta/image-3.webp"
alt="Nuvemshop Logo"
/>
);
}

Optionally, the Img component can receive alternative sources loaded by media query.

Example
export function Logo() {
return (
<Image
src="https://hostname/default.png"
alt="Hello"
sources={[
{
src: "https://hostname/desktop.png",
media: "(min-width: 769px)",
},
{
src: "https://hostname/mobile.png",
media: "(max-width: 768px)",
},
]}
/>
);
}

Properties

PropertyTypeRequiredDescription
srcstringYesURL of the image to display. Must use "https://".
altstringYesAlternative text for the image, used for accessibility.
sourcesImageSource[]NoArray of alternative image sources with optional media queries.
widthSizeNoWidth of the image (e.g., "100px", "50%", "auto", 100).
heightSizeNoHeight of the image (same format as width).
idstringNoOptional unique identifier for the component.
styleStyleSheetNoCustom styles for the image.

ImageSource

PropertyTypeRequiredDescription
srcstringYesThe alternative image source URL (https only).
mediastringNoOptional media query to match this source.