Skip to content

Component Image

MeowLynxSea edited this page Jan 24, 2026 · 5 revisions

Image

Displays an image with loading + fallback placeholders.

Image supports two sources:

  • Embedded Arc<gpui::Image>
  • A file path (PathBuf)

Example

use std::sync::Arc;
use gpui::Image;
use yororen_ui::component::image;

let img: Arc<Image> = yororen_ui::component::image_from_bytes(vec![]);
let view = image(img);

When to use

  • Thumbnails and content images
  • Displaying local images from a file path

API

  • image(source): constructor (source can be Arc<Image> or PathBuf)
  • fit(ImageFit):
    • Contain (default)
    • Cover

Helper:

  • image_from_bytes(Vec<u8>) -> Arc<Image>: convenience to build a PNG image

Notes

  • The view uses with_loading(...) and with_fallback(...) placeholders.

Defaults

  • Fit: ImageFit::Contain
  • Placeholder background: theme.surface.sunken

Clone this wiki locally