Feed#

Open this notebook in Jupyterlite | Download this notebook from GitHub (right-click to download).


Material version available

pn.ui.Feed resolves to the Material Design implementation of this component, documented in the panel-material-ui reference. This page documents the classic pn.layout.Feed.

import panel as pn
pn.extension()

The Feed layout inherits from the Column layout and arranges multiple Panel objects in a vertical, scrollable container, but limits the number of objects rendered at any given moment. This makes it well suited for displaying very long lists of outputs, such as logs or chat messages.

Like Column, it has a list-like API with methods to append, extend, clear, insert, pop, remove and __setitem__, which make it possible to interactively update and modify the layout.

Parameters:#

For details on other options for customizing the component see the layout and styling how-to guides.

  • objects (list): The list of objects to display in the Feed, should not generally be modified directly except when replaced in its entirety.

  • load_buffer (int): The number of objects loaded on each side of the visible objects. When scrolled halfway into the buffer, the Feed will automatically load additional objects while unloading objects on the opposite side.

  • scroll (boolean or str, default=’y’): Whether to add scrollbars if the content overflows the size of the container. Only a scrolling Feed limits the number of rendered objects; if no height, min_height or max_height is provided it defaults to a height of 300 pixels.

  • scroll_position (int): Current scroll position of the Feed. Setting this value will update the scroll position of the Feed. Setting to 0 will scroll to the top.

  • auto_scroll_limit (int): Max pixel distance from the latest object in the Feed to activate automatic scrolling upon update. Setting to 0 disables auto-scrolling

  • scroll_button_threshold (int): Min pixel distance from the latest object in the Feed to display the scroll button. Setting to 0 disables the scroll button.

  • view_latest (bool): Whether to scroll to the latest object on init. If not enabled the view will be on the first object.

  • visible_range (list): Read-only upper and lower bounds of the currently visible Feed objects. This list is automatically updated based on scrolling.

Methods:#

  • scroll_to(index: int): Scrolls the Feed to the object at the specified index.

  • scroll_to_latest(scroll_limit: float | None = None): Scrolls the Feed to the latest object, optionally only if it is within scroll_limit pixels of the bottom.


When scrolled halfway into the load_buffer, the Feed will automatically load additional entries while unloading entries on the opposite side:

feed = pn.Feed(*list(range(1000)), load_buffer=20)
feed

To have the Feeds immediately initialized at the latest entry, set view_latest=True.

feed = pn.Feed(*list(range(1000)), view_latest=True)
feed

Additionally, to allow users to scroll to the bottom interactively, set a scroll_button_threshold which will make the Feed display a clickable scroll button.

feed = pn.Feed(*list(range(1000)), scroll_button_threshold=20, width=300)
feed

The read-only visible_range parameter reports the indexes of the objects currently in view and updates as the user scrolls. Passing the parameter to a pane lets us display it alongside the Feed in a live session:

pn.Row(feed, pn.pane.Str(feed.param.visible_range))

The Feed can also be scrolled programmatically. Here we append a new entry and then call scroll_to_latest to bring it into view:

feed.append('A new entry')
feed.scroll_to_latest()

Open this notebook in Jupyterlite | Download this notebook from GitHub (right-click to download).