Using Button Menus#


A ButtonMenuPages class is provided for pagination with button components.

ButtonMenuPages works the same way as MenuPages, but with Button components instead of reactions.

A nextcord.ButtonStyle can optionally be passed in to customize the appearance of the buttons.

The PageSource deals with the data representation and formatting of the data we want to paginate.

MySource is the same as defined earlier, but the menu is instantiated with ButtonMenuPages as follows:

from nextcord.ext import menus

class MySource(menus.ListPageSource):
    def __init__(self, data):
        super().__init__(data, per_page=4)

    async def format_page(self, menu, entries):
        offset = menu.current_page * self.per_page
        return '\n'.join(f'{i}. {v}' for i, v in enumerate(entries, start=offset))

async def pages_example(ctx):
    data = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
    pages = menus.ButtonMenuPages(
    await pages.start(ctx)