pub struct CarouselItem {
pub image_src: String,
pub image_alt: String,
pub caption_title: Option<String>,
pub caption_text: Option<String>,
pub active: bool,
}Expand description
A carousel slide item.
Fields§
§image_src: String§image_alt: String§caption_title: Option<String>§caption_text: Option<String>§active: boolImplementations§
Source§impl CarouselItem
impl CarouselItem
Sourcepub fn new(src: impl Into<String>, alt: impl Into<String>) -> Self
pub fn new(src: impl Into<String>, alt: impl Into<String>) -> Self
Create a new carousel item.
Examples found in repository?
examples/bootstrap_docs.rs (lines 651-654)
638fn carousel_section() -> Element<Section> {
639 Element::<Section>::new()
640 .attr("id", "carousel")
641 .class("mb-5")
642 .child::<H2, _>(|h| h.class("border-bottom pb-2").text("Carousel"))
643 .child::<P, _>(|p| {
644 p.class("lead")
645 .text("A slideshow component for cycling through elements.")
646 })
647 .child::<H4, _>(|h| h.class("mt-4").text("Basic Example"))
648 .child::<Div, _>(|d| {
649 d.class("bd-example mb-3").child::<Div, _>(|_| {
650 let items = vec![
651 carousel::CarouselItem::new(
652 "https://via.placeholder.com/800x400/007bff/ffffff?text=First+Slide",
653 "First slide",
654 )
655 .active()
656 .caption(
657 "First slide label",
658 "Some representative placeholder content.",
659 ),
660 carousel::CarouselItem::new(
661 "https://via.placeholder.com/800x400/6c757d/ffffff?text=Second+Slide",
662 "Second slide",
663 )
664 .caption("Second slide label", "Some more placeholder content."),
665 carousel::CarouselItem::new(
666 "https://via.placeholder.com/800x400/28a745/ffffff?text=Third+Slide",
667 "Third slide",
668 )
669 .caption("Third slide label", "Even more placeholder content."),
670 ];
671 carousel::carousel_with_indicators("carouselExample", &items)
672 })
673 })
674}Sourcepub const fn active(self) -> Self
pub const fn active(self) -> Self
Mark this slide as active.
Examples found in repository?
examples/bootstrap_docs.rs (line 655)
638fn carousel_section() -> Element<Section> {
639 Element::<Section>::new()
640 .attr("id", "carousel")
641 .class("mb-5")
642 .child::<H2, _>(|h| h.class("border-bottom pb-2").text("Carousel"))
643 .child::<P, _>(|p| {
644 p.class("lead")
645 .text("A slideshow component for cycling through elements.")
646 })
647 .child::<H4, _>(|h| h.class("mt-4").text("Basic Example"))
648 .child::<Div, _>(|d| {
649 d.class("bd-example mb-3").child::<Div, _>(|_| {
650 let items = vec![
651 carousel::CarouselItem::new(
652 "https://via.placeholder.com/800x400/007bff/ffffff?text=First+Slide",
653 "First slide",
654 )
655 .active()
656 .caption(
657 "First slide label",
658 "Some representative placeholder content.",
659 ),
660 carousel::CarouselItem::new(
661 "https://via.placeholder.com/800x400/6c757d/ffffff?text=Second+Slide",
662 "Second slide",
663 )
664 .caption("Second slide label", "Some more placeholder content."),
665 carousel::CarouselItem::new(
666 "https://via.placeholder.com/800x400/28a745/ffffff?text=Third+Slide",
667 "Third slide",
668 )
669 .caption("Third slide label", "Even more placeholder content."),
670 ];
671 carousel::carousel_with_indicators("carouselExample", &items)
672 })
673 })
674}Sourcepub fn caption(self, title: impl Into<String>, text: impl Into<String>) -> Self
pub fn caption(self, title: impl Into<String>, text: impl Into<String>) -> Self
Add a caption to this slide.
Examples found in repository?
examples/bootstrap_docs.rs (lines 656-659)
638fn carousel_section() -> Element<Section> {
639 Element::<Section>::new()
640 .attr("id", "carousel")
641 .class("mb-5")
642 .child::<H2, _>(|h| h.class("border-bottom pb-2").text("Carousel"))
643 .child::<P, _>(|p| {
644 p.class("lead")
645 .text("A slideshow component for cycling through elements.")
646 })
647 .child::<H4, _>(|h| h.class("mt-4").text("Basic Example"))
648 .child::<Div, _>(|d| {
649 d.class("bd-example mb-3").child::<Div, _>(|_| {
650 let items = vec![
651 carousel::CarouselItem::new(
652 "https://via.placeholder.com/800x400/007bff/ffffff?text=First+Slide",
653 "First slide",
654 )
655 .active()
656 .caption(
657 "First slide label",
658 "Some representative placeholder content.",
659 ),
660 carousel::CarouselItem::new(
661 "https://via.placeholder.com/800x400/6c757d/ffffff?text=Second+Slide",
662 "Second slide",
663 )
664 .caption("Second slide label", "Some more placeholder content."),
665 carousel::CarouselItem::new(
666 "https://via.placeholder.com/800x400/28a745/ffffff?text=Third+Slide",
667 "Third slide",
668 )
669 .caption("Third slide label", "Even more placeholder content."),
670 ];
671 carousel::carousel_with_indicators("carouselExample", &items)
672 })
673 })
674}Auto Trait Implementations§
impl Freeze for CarouselItem
impl RefUnwindSafe for CarouselItem
impl Send for CarouselItem
impl Sync for CarouselItem
impl Unpin for CarouselItem
impl UnwindSafe for CarouselItem
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
Mutably borrows from an owned value. Read more