Module freya_elements::elements::image
source · Expand description
image
element let’s you show an image.
For dynamic Images you may use dynamic_bytes
.
§Example
ⓘ
static RUST_LOGO: &[u8] = include_bytes!("./rust_logo.png");
fn app() -> Element {
let image_data = static_bytes(RUST_LOGO);
rsx!(
image {
image_data,
width: "100%", // You must specify size otherwhise it will default to 0
height: "100%",
}
)
}
Constants§
aspect_ratio
controls how animage
element is rendered when facing unexpected dimensions.cache_key
lets you specify an unique identifier for the given image. This will help Freya cache the image decoding, if the cache_key changes the old cache will be pruned and the image (changed or not) will be decoded again.cache_key
is optinal but its recommended to be used, specialy for high quality images. You can pass any value that can be transformed into a string. Like a URL.- Specify how you want the automatic (e.g
width: auto
) bounds in the cross axis to be constrained for the inner elements. cover
controls how animage
element position is rendered inside the given dimensions.- cross_align
- Control how the inner elements stack.
- Specify the height for the given element.
- Specify the image data for the image element.
- Specify an image reference handle for the image element.
- Controls the stacking order of elements on the z-axis.
- main_align
- Specify the margin of an element. You can do so by four different ways, just like in CSS.
- Specify a maximum height for the given element.
- Specify a maximum width for the given element.
- Specify a minimum height for the given element. This can be useful if you use it alongside a percentage for the target size.
- Specify a minimum width for the given element. This can be useful if you use it alongside a percentage for the target size.
- Moves the content inside of the container horizontally by the specified pixel amount. This attribute only supports pixels.
- Moves the content inside of the container vertically by the specified pixel amount. This attribute only supports pixels.
- Specify the opacity for this element.
- Specify how overflow should be handled.
- Specify how you want the element to be positioned inside it’s parent area.
- Specify the bottom position of an element when using
position: "absolute"
orposition: "global"
. This supports pixels only. - Specify the left position of an element when using
position: "absolute"
orposition: "global"
. This supports pixels only. - Specify the right position of an element when using
position: "absolute"
orposition: "global"
. This supports pixels only. - Specify the top position of an element when using
position: "absolute"
orposition: "global"
. This supports pixels only. - Attach a reference to an element to track its layout and metadata.
- Specify the rotation for this element.
sampling
controls how animage
element is resized when scaling from its original size to smaller or larger sizes.- Specify a space between the inner elements. Think it as a margin for every element but defined by its parent. It only applies to the side of the direction.
- Specify the width for the given element.