Image

An img that puts a fallback in its place when there is no source or the file fails to load, sized by its className and square-cornered by default.

Picture
import { Image } from "@produkto/ui/Image";

const Example = () => (
  <Image
    alt="Picture"
    className="w-full max-w-sm"
    src="https://images.unsplash.com/photo-1497366754035-f200968a6e72?w=900&auto=format&fit=crop&q=80"
  />
);

export default Example;

Usage

import { Image } from "@produkto/ui/Image";
<Image alt="Picture" src="/picture.jpg" />

Examples

Border radius

borderRadius rounds the picture, or the box standing in for it, on the kit's one scale: none, the default, square-cornered, xs 4px, sm 6px, base 8px, lg 12px, xl 16px, or full to round it.

Picture
Picture
Picture
Picture
Picture
Picture
Picture
import { Image, type ImageBorderRadius } from "@produkto/ui/Image";
import { Label } from "@produkto/ui/Label";

const radii: ImageBorderRadius[] = [
  "none",
  "xs",
  "sm",
  "base",
  "lg",
  "xl",
  "full",
];

const src: string =
  "https://images.unsplash.com/photo-1497215728101-856f4ea42174?w=160&h=160&auto=format&fit=crop&q=80";

const Example = () => (
  <div className="flex flex-wrap items-start gap-6">
    {radii.map((borderRadius) => (
      <div className="flex flex-col items-center gap-2" key={borderRadius}>
        <Label>{borderRadius}</Label>
        <Image
          alt="Picture"
          height={80}
          borderRadius={borderRadius}
          src={src}
          width={80}
        />
      </div>
    ))}
  </div>
);

export default Example;

Fallback

With no source, as by default, or a file that fails to load, a box of the width and height given stands in: an icon, or its children in the icon's place.

import { Image } from "@produkto/ui/Image";

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    <Image alt="Picture" height={96} width={96} />
    <Image alt="User 1" height={96} width={96}>
      U1
    </Image>
  </div>
);

export default Example;

API Reference

Image

ImageProps ยท components/Image/Image.types.ts
PropTypeDefault
srcstring-
borderRadiusImageBorderRadius"none" | "xs" | "sm" | "base" | "lg" | "xl" | "full""none"
altstring""

It also takes the props of <img>.