Image
A Duostrap image component providing classic default, rounded, polaroid, and circle treatments over Base Image.
Duostrap Image preserves the archived .img-rounded, .img-polaroid, and .img-circle image treatments while delegating source management, object-fit sizing, accessibility modes, and live loading status events to Base Image.
Preview
Section titled “Preview”<div class="grid max-w-2xl grid-cols-4 gap-4">
<wc-duostrap-image-root
source="/images/base-image/portrait.svg"
alternative-text="Default image"
fit="cover"
appearance="default"
></wc-duostrap-image-root>
<wc-duostrap-image-root
source="/images/base-image/portrait.svg"
alternative-text="Rounded image"
fit="cover"
appearance="rounded"
></wc-duostrap-image-root>
<wc-duostrap-image-root
source="/images/base-image/portrait.svg"
alternative-text="Polaroid image"
fit="cover"
appearance="polaroid"
></wc-duostrap-image-root>
<wc-duostrap-image-root
source="/images/base-image/portrait.svg"
alternative-text="Circle image"
fit="cover"
appearance="circle"
></wc-duostrap-image-root>
</div>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases. Import imageRoot (aliased as duostrapImageRoot) and DuostrapImageRootProps directly from @proto.ui/prototypes-duostrap/image.
import * as React from 'react';import { createReactAdapter } from '@proto.ui/adapter-react';import { duostrapImageRoot } from '@proto.ui/prototypes-duostrap/image';
const BootstrapImage = createReactAdapter(React)(duostrapImageRoot);
export function FramedPortrait() { return ( <BootstrapImage source="/images/base-image/portrait.svg" a11yMode="informative" alternativeText="Portrait framed with Duostrap polaroid trim" fit="cover" appearance="polaroid" surfaceStyle={{ width: '160px', height: '160px' }} /> );}- Appearances (
appearance):default: Responsive borderless image (max-w-full h-auto align-middle border-0).rounded: Classic6pxrounded corners (.img-rounded).polaroid:4pxwhite frame padding,1px rgba(0, 0, 0, 0.2)border, and subtle drop shadow (.img-polaroid).circle: Historical500pxradius (.img-circle); pair with a 1:1 square container for a true circular crop.
- Accessibility and loading:
a11yMode,alternativeText,fit,loadingStatus, andloadingStatusChangeare inherited directly from Base Image.
Examples
Section titled “Examples”Fit Modes
Section titled “Fit Modes”Compare contain, cover, and fill using appearance="rounded".
<div class="grid max-w-2xl grid-cols-3 gap-4">
<wc-duostrap-image-root
source="/images/base-image/landscape.svg"
alternative-text="Mountain ridge (contain)"
fit="contain"
appearance="rounded"
></wc-duostrap-image-root>
<wc-duostrap-image-root
source="/images/base-image/landscape.svg"
alternative-text="Mountain ridge (cover)"
fit="cover"
appearance="rounded"
></wc-duostrap-image-root>
<wc-duostrap-image-root
source="/images/base-image/landscape.svg"
alternative-text="Mountain ridge (fill)"
fit="fill"
appearance="rounded"
></wc-duostrap-image-root>
</div>Accessibility
Section titled “Accessibility”Compare an informative polaroid figure against a 1:1 circular decorative thumbnail.
<div class="flex max-w-xl flex-col gap-4">
<wc-duostrap-image-root
source="/images/base-image/landscape.svg"
a11y-mode="informative"
alternative-text="Sunlit mountain ridge"
fit="cover"
appearance="polaroid"
></wc-duostrap-image-root>
<wc-duostrap-image-root
source="/images/base-image/portrait.svg"
a11y-mode="decorative"
fit="cover"
appearance="circle"
></wc-duostrap-image-root>
</div>Loading & Fallback
Section titled “Loading & Fallback”Switch sources with Duostrap buttons and render an application-owned fallback card with retry when loading fails or clears.
<div class="flex max-w-lg flex-col gap-4">
<wc-duostrap-image-root
source="/images/base-image/landscape.svg"
a11y-mode="informative"
alternative-text="Selected landscape scene"
fit="cover"
appearance="polaroid"
></wc-duostrap-image-root>
<div class="flex flex-wrap gap-2">
<wc-duostrap-button variant="primary" size="small">
Landscape
</wc-duostrap-button>
<wc-duostrap-button variant="default" size="small">
Portrait
</wc-duostrap-button>
<wc-duostrap-button variant="danger" size="small">
Broken URL
</wc-duostrap-button>
</div>
</div>Root Props
Section titled “Root Props”| Prop | Type | Default |
|---|---|---|
source | string undefined | undefined |
a11yMode | 'informative' 'decorative' | informative |
alternativeText | string | '' |
fit | 'contain' 'cover' 'fill' | contain |
appearance | 'default' 'rounded' 'polaroid' 'circle' | default |
Exposes & Events
Section titled “Exposes & Events”| Name | Type | Description |
|---|---|---|
source | ExposeState<string> | Active image source URI |
fit | ExposeState<'contain' 'cover' 'fill'> | Current object-fit mode |
loadingStatus | ExposeState<'idle' 'loading' 'loaded' 'error'> | Current image load lifecycle state |
loadingStatusChange | ExposeEvent<{ status, previousStatus, source }> | Emitted on status transitions (bind via onLoadingStatusChange in React/Vue) |