Image
Image primitive with skeleton and fallback support.
Preview
A live, theme-aware example rendered with the published component.
Loading preview…
Import
Import the component from its dedicated entry point to keep the dependency and generated bundle explicit.
tsximport { Image } from "@tavojs/ui/image";Normal Tavo.js applications load component styles through the Tavo.js UI plugin. If the application manages component CSS manually, also import @tavojs/ui/css/image.
When to use
Use it when
Choose something else when
Examples
Image example
tsximport { Image } from "@tavojs/ui/image";
export function ImageExample1() {
return (
<>
<Image src="/preview.png" alt="Dashboard preview" width="100%" height={320} objectFit="cover" />
</>
);
}Common props and defaults
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Optional class hook applied to the public root element owned by the component. |
src | string | — | Configures src for this component. |
alt | string | — | Configures alt for this component. |
width | number | string | — | Configures width for this component. |
height | number | string | — | Configures height for this component. |
objectFit | "cover" | "contain" | "fill" | "none" | "scale-down" | — | Configures objectFit for this component. |
skeleton | "text" | "circular" | "rectangular" | "rounded" | — | Configures skeleton for this component. |
fallback | string | — | Configures fallback for this component. |
widths | number[] | — | Configures widths for this component. |
Complete TypeScript API
Import from @tavojs/ui/image. Published exports: Image, ImageProps.
ImageProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Inherited children attribute accepted by Image. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
sx | Sx | No | Inherited sx attribute accepted by Image. |
id | string | No | Inherited id attribute accepted by Image. |
role | string | No | Inherited role attribute accepted by Image. |
style | Record<string, unknown> | No | Inherited style attribute accepted by Image. |
title | string | No | Inherited title attribute accepted by Image. |
tabIndex | number | No | Inherited tabIndex attribute accepted by Image. |
hidden | boolean | No | Inherited hidden attribute accepted by Image. |
disabled | boolean | No | Inherited disabled attribute accepted by Image. |
onClick | TavoEventHandler<MouseEvent> | No | Inherited onClick attribute accepted by Image. |
onChange | TavoEventHandler<Event> | No | Inherited onChange attribute accepted by Image. |
onInput | TavoEventHandler<Event> | No | Inherited onInput attribute accepted by Image. |
onKeyDown | TavoEventHandler<KeyboardEvent> | No | Inherited onKeyDown attribute accepted by Image. |
onFocus | TavoEventHandler<FocusEvent> | No | Inherited onFocus attribute accepted by Image. |
onBlur | TavoEventHandler<FocusEvent> | No | Inherited onBlur attribute accepted by Image. |
src | string | No | Configures src for this component. |
alt | string | No | Configures alt for this component. |
width | string | number | No | Configures width for this component. |
height | string | number | No | Configures height for this component. |
objectFit | "none" | "cover" | "contain" | "fill" | "scale-down" | No | Configures objectFit for this component. |
skeleton | "text" | "circular" | "rectangular" | "rounded" | No | Configures skeleton for this component. |
fallback | string | No | Configures fallback for this component. |
State ownership and DOM target
| Concern | Contract |
|---|---|
| State | No component state contract is exposed; the application owns the rendered content and surrounding behavior. |
| DOM target | Public passthrough props target the component root. Treat nested elements and private class names as implementation details. |
Anatomy and related components
This component exposes one public component root rather than a compound member API.
Limitations
Avoid Image when replacing interactive controls with content-only components.
Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.
Accessibility
Content components should keep meaningful text and media alternatives available to assistive technology.
Provide alt text for meaningful images.
Use semantic text variants for headings and paragraphs.
Do not hide essential content visually unless VisuallyHidden is intentional.
Component status
| Contract | Current value |
|---|---|
| Maturity | stable |
| Category | content |
| Component import | @tavojs/ui/image |
| Explicit CSS import | @tavojs/ui/css/image |
| Preview | Interactive preview available on this page |