pub struct ImageProps {Show 26 fields
pub src: &'static str,
pub alt: &'static str,
pub fallback_src: &'static str,
pub width: &'static str,
pub height: &'static str,
pub style: &'static str,
pub class: &'static str,
pub sizes: &'static str,
pub loading: Loading,
pub placeholder: &'static str,
pub on_load: Option<Callback<()>>,
pub object_fit: ObjectFit,
pub object_position: Position,
pub on_error: Option<Callback<String>>,
pub decoding: Decoding,
pub blur_data_url: &'static str,
pub layout: Layout,
pub node_ref: NodeRef<Img>,
pub srcset: &'static str,
pub crossorigin: CrossOrigin,
pub referrerpolicy: ReferrerPolicy,
pub usemap: &'static str,
pub ismap: bool,
pub fetchpriority: FetchPriority,
pub elementtiming: &'static str,
pub attributionsrc: &'static str,
}lep only.Expand description
Props for the Image component.
ยงOptional Props
- src: [
&'static str]-
The source URL of the image.
This is the primary image that will be rendered.
-
- alt: [
&'static str]-
The alternative text for the image.
Used for accessibility and shown if the image cannot be displayed.
-
- fallback_src: [
&'static str]- A fallback image URL if the main image fails to load.
- width: [
&'static str]- Width of the image (e.g., โ100pxโ, โautoโ).
- height: [
&'static str]- Height of the image (e.g., โ100pxโ, โautoโ).
- style: [
&'static str]- Inline styles applied to the image.
- class: [
&'static str]- CSS class name(s) to apply to the image.
- sizes: [
&'static str]- Image
sizesattribute for responsive loading.
- Image
- loading:
Loading- Defines how the image is loaded. Defaults to lazy loading.
- placeholder: [
&'static str]- Placeholder content shown while the image loads.
- on_load: [
Callback<()>]- Callback function fired when the image is successfully loaded.
- object_fit:
ObjectFit- Specifies how the image should be resized to fit its container.
- object_position:
Position- Specifies the position of the image within its container.
- on_error:
Callback<String>- Callback function fired when the image fails to load.
- decoding:
Decoding- Specifies how the image should be decoded (auto, sync, async).
- blur_data_url: [
&'static str]- Base64-encoded blurred image shown before the main image loads.
- layout:
Layout- Controls how the image is laid out inside its container.
- node_ref:
NodeRef<Img>- Reference to the image DOM element.
- srcset: [
&'static str]- One or more image sources with descriptors (e.g., โimg-1x.jpg 1x, img-2x.jpg 2xโ).
- crossorigin:
CrossOrigin- CORS policy for fetching the image (none, anonymous, use-credentials).
- referrerpolicy:
ReferrerPolicy- Referrer policy when fetching the image.
- usemap: [
&'static str]- Associates the image with an image map.
- ismap:
bool- Indicates the image is part of a server-side image map.
- fetchpriority:
FetchPriority- Fetch priority hint for the browser (auto, high, low).
- elementtiming: [
&'static str]- Identifier for performance element timing.
- attributionsrc: [
&'static str]- Indicates the current item in a set for accessibility. ID reference to the element describing this image. Whether the associated content is expanded or collapsed. Whether the image is hidden from assistive technologies. #[prop(optional)] aria_hidden: &โstatic str, Indicates the pressed state of the image if itโs used as a toggle. ID reference to the element this image controls. ID reference to the element that labels this image. Indicates whether updates to the image are live. URLs for Attribution Reporting (experimental feature).
Fieldsยง
ยงsrc: &'static strThe source URL of the image.
This is the primary image that will be rendered.
alt: &'static strThe alternative text for the image.
Used for accessibility and shown if the image cannot be displayed.
fallback_src: &'static strA fallback image URL if the main image fails to load.
width: &'static strWidth of the image (e.g., โ100pxโ, โautoโ).
height: &'static strHeight of the image (e.g., โ100pxโ, โautoโ).
style: &'static strInline styles applied to the image.
class: &'static strCSS class name(s) to apply to the image.
sizes: &'static strImage sizes attribute for responsive loading.
loading: LoadingDefines how the image is loaded. Defaults to lazy loading.
placeholder: &'static strPlaceholder content shown while the image loads.
on_load: Option<Callback<()>>Callback function fired when the image is successfully loaded.
object_fit: ObjectFitSpecifies how the image should be resized to fit its container.
object_position: PositionSpecifies the position of the image within its container.
on_error: Option<Callback<String>>Callback function fired when the image fails to load.
decoding: DecodingSpecifies how the image should be decoded (auto, sync, async).
blur_data_url: &'static strBase64-encoded blurred image shown before the main image loads.
layout: LayoutControls how the image is laid out inside its container.
node_ref: NodeRef<Img>Reference to the image DOM element.
srcset: &'static strOne or more image sources with descriptors (e.g., โimg-1x.jpg 1x, img-2x.jpg 2xโ).
crossorigin: CrossOriginCORS policy for fetching the image (none, anonymous, use-credentials).
referrerpolicy: ReferrerPolicyReferrer policy when fetching the image.
usemap: &'static strAssociates the image with an image map.
ismap: boolIndicates the image is part of a server-side image map.
fetchpriority: FetchPriorityFetch priority hint for the browser (auto, high, low).
elementtiming: &'static strIdentifier for performance element timing.
attributionsrc: &'static strIndicates the current item in a set for accessibility. ID reference to the element describing this image. Whether the associated content is expanded or collapsed. Whether the image is hidden from assistive technologies. #[prop(optional)] aria_hidden: &โstatic str, Indicates the pressed state of the image if itโs used as a toggle. ID reference to the element this image controls. ID reference to the element that labels this image. Indicates whether updates to the image are live. URLs for Attribution Reporting (experimental feature).
Implementationsยง
Sourceยงimpl ImageProps
impl ImageProps
Sourcepub fn builder() -> ImagePropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
pub fn builder() -> ImagePropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
Create a builder for building ImageProps.
On the builder, call .src(...)(optional), .alt(...)(optional), .fallback_src(...)(optional), .width(...)(optional), .height(...)(optional), .style(...)(optional), .class(...)(optional), .sizes(...)(optional), .loading(...)(optional), .placeholder(...)(optional), .on_load(...)(optional), .object_fit(...)(optional), .object_position(...)(optional), .on_error(...)(optional), .decoding(...)(optional), .blur_data_url(...)(optional), .layout(...)(optional), .node_ref(...)(optional), .srcset(...)(optional), .crossorigin(...)(optional), .referrerpolicy(...)(optional), .usemap(...)(optional), .ismap(...)(optional), .fetchpriority(...)(optional), .elementtiming(...)(optional), .attributionsrc(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of ImageProps.
Trait Implementationsยง
Auto Trait Implementationsยง
impl Freeze for ImageProps
impl RefUnwindSafe for ImageProps
impl Send for ImageProps
impl Sync for ImageProps
impl Unpin for ImageProps
impl UnwindSafe for ImageProps
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Sourceยงfn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Sourceยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงimpl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Sourceยงfn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self to a value of a Properties struct.Sourceยงimpl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Sourceยงfn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self to a value of a Properties struct.