Component field guide

Explore live variants, compare states, and learn every prop. Pick a component to start.

LIVE COMPONENT

WelkImage

A native image inside an uneven comic frame. Network mode replaces a failed image with a fallback and displays an Unable to load image status label. Asset mode leaves image errors to native behavior. Supply dimensions to reserve layout space.

Comic artwork

Usage

React / TSX
import { WelkImage } from "@welkui/react";
import comic from "./comic.jpg";

<WelkImage variant="asset" src={comic} alt="Comic artwork"
  width={400} height={220} />

Import @welkui/react/styles.css once in your app. Stateful snippets belong inside a React component.

Variants and behavior

  • network: fallback-aware image (default).
  • asset: native loading/error behavior for bundled artwork.

Visual variant gallery

These are real components, not screenshots. Compare their appearance and try the controls. Key props below each preview show what changes; use the usage example above for imports and component setup.

Local asset

Bundled artwork in the irregular frame. Set alt text and reserve space with dimensions.

Local comic panel
Key propsvariant="asset" src={comic}

Network mode

Paste a public image URL above the preview. Changes load immediately; inaccessible or invalid images show a fallback and an error message.

Network image preview
Key propsvariant="network" src={url}

Load failure and fallback

A deliberately invalid image demonstrates fallbackSrc and the visible error status.

Fallback comic panel
Key propssrc={brokenImage} fallbackSrc={comic}

Usage notes and accessibility

  • Use alt text that explains the image's purpose. Use an empty alt for decorative images and put essential information in surrounding text too.
  • Reserve layout space with width/height and use a responsive style where needed. Native loading=lazy can defer non-critical images.
  • Network mode falls back to bundled artwork or fallbackSrc and shows an error label. Asset mode keeps native error handling. Paste a public image URL into the network example to try it; the image host must allow access from your browser.

Props

Required props are marked in the default column. Other props are optional. ReactNode accepts text or JSX.

WelkImage prop reference
PropTypeDefaultDescription
srcstringRequiredImage URL or imported local asset.
altstringRequiredAccessible image description; use "" for purely decorative artwork.
fallbackSrcstringBundled comic artworkReplacement image after a network-mode load failure.
variant"network" | "asset""network"Image error-handling mode; fallbackSrc is used in network mode.

Native props and refs

Inherits native image props except src, alt and children, including width, height, loading, decoding, onLoad, onError, className and style; forwards an image ref.

Project setup, styling and Next.js

Import @welkui/react/styles.css once in your app entry or Next.js root layout. The previews use the default theme; override --welk-* CSS tokens in your app to customize it.

For Next.js, put hooks and event handlers in a component beginning with "use client". Keep state local to the component using the control. The library preserves its client boundaries and uses your installed React version.

Use defaultValue or defaultChecked for uncontrolled fields, or a state value and its change callback for controlled fields. Do not switch between these modes during the lifetime of a field.

Modal and notification examples start closed: use their Try buttons to see them. Disabled examples are deliberately non-interactive. Validate forms, uploads, authentication, and server responses in your application; these components only provide UI.