Skip to content

Conversation

@andrewsoonqn
Copy link
Contributor

@andrewsoonqn andrewsoonqn commented Jan 7, 2026

📝 Summary

This PR implements wrap around functionality to mo.carousel() such that a carousel can be allowed to jump back to the start of the array when scrolling beyond the last item (or vice versa, back to last item from the first by clicking the left arrow)

Fixes #5001

🔍 Description of Changes

  • Added wrapAround prop to SlideComponent. This will be used to set Swiper's loop property, which directly gives the ability to wrap around.
  • wrapAround is always True when using CarouselPlugin

Demo:

Screen.Recording.2026-01-08.at.16.57.57.mov

Note:

  • did not implement new tests: assumed no extra tests needed as no existing tests for mo.carousel() were found to be added onto

📋 Checklist

  • I have read the contributor guidelines.
  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • I have added tests for the changes made.
  • I have run the code and verified that it works as expected.

Introduces a new 'wrapAround' boolean prop to SlidesComponent, allowing slides to loop when enabled by passing it to the Swiper's 'loop' property.
Add wrapAround to `CarouselPlugin` and ability to toggle in `SlidesComponent`
Copilot AI review requested due to automatic review settings January 7, 2026 14:26
@vercel
Copy link

vercel bot commented Jan 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jan 8, 2026 9:01am

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@andrewsoonqn
Copy link
Contributor Author

andrewsoonqn commented Jan 7, 2026

I have read the CLA Document and I hereby sign the CLA

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements wrap around functionality for mo.carousel(), allowing carousels to loop back to the start when navigating beyond the last item (or to the last item from the first).

  • Added a wrapAround parameter to mo.carousel() to enable/disable wrap around behavior
  • Integrated Swiper's loop property to implement the wrap around feature
  • Handled the incompatibility between Swiper's virtual and loop properties by conditionally disabling virtual mode when wrap around is enabled

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
marimo/_plugins/stateless/carousel.py Added wrapAround parameter to the carousel function and passed it to the frontend via build_stateless_plugin
frontend/src/plugins/layout/carousel/CarouselPlugin.tsx Added wrapAround field to the Data interface and validator schema
frontend/src/components/slides/slides-component.tsx Implemented wrap around logic by conditionally enabling Swiper's loop property and disabling virtual mode when loop is active

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Updated the carousel function parameter from wrapAround to wrap_around for consistency with Python naming conventions. Adjusted all references and docstrings accordingly.
@Light2Dark
Copy link
Contributor

hi @andrewsoonqn , I left a comment on the issue, I dont think we need to update the backend code

Copy link
Contributor

@akshayka akshayka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Let's not add an argument to the carousel Python function, however. The carousel should just always wrap; wrapping should not be configurable

`CarouselPlugin` will now always pass a wrapAround value of `True` to the `SlideComponent`. Reverted changes to backend.
@Light2Dark Light2Dark added the enhancement New feature or request label Jan 8, 2026
@Light2Dark Light2Dark merged commit f948d8d into marimo-team:main Jan 8, 2026
31 of 34 checks passed
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.18.5-dev183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrap around mo.carousel()

4 participants