Image
Image primitive with skeleton and fallback support.
Preview
A live, theme-aware example rendered with the published component.
Loading preview…
Import
Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.
tsximport { Image } from "@tavojs/ui/image";The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/image.
When to use
Use it when
Choose something else when
Examples
These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.
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
A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.
| 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 |