#

In 
Navs

# nav_js_tag


nav_js_tag functions similarly to a nav_tag, with the following added features:

  1. Enables client-side rendering.
  2. Provides optional responsiveness.
  3. Improves performance and optimizes resource usage (see Maximizing Performance).

Responsive nav_js_tag (:bootstrap style)
Responsive nav_js_tag (:bootstrap style)

Try it now!

<%== @pagy.nav_js_tag(**options %>  <%# default pagy style %>
<%== @pagy.nav_js_tag(:bootstrap, **options) %>
<%== @pagy.nav_js_tag(:bulma, **options) %>

See Common Nav Styles

  • steps: { 0 => 5, 540 => 7, 720 => 9 }
    • Enable responsiveness. Assign different number of :slots to different tag widths.

See also other applicabe options: nav_tag Options

Notice: when :steps is not set, the nav_js_tag behaves exactly as a nav_tag: just faster.

Set it as a hash, where the keys are integers representing the widths in pixels, and the values are the :slots options to be applied for those widths.

For example:

{ 0 => 5, 540 => 7, 720 => 9 } means that from 0 to 540 pixels width, Pagy will use 5 slots, from 540 to 720 it will use 7 slots, and over 720 it will use 9 slots. (Read more about the :slots option in the How to control the pagination bar section.)

# Setting the right steps

Setting the :steps can enhance responsiveness and ensure seamless transitions.

Consider these guidelines to achieve optimal results:

  1. Define discrete :steps using width/slots pairs to control the pagination behavior.

  2. Ensure the container's width accommodates all slots for a smooth transition as it resizes.

  3. Synchronize the pagy :steps with your container's discrete width changes, for consistent alignment.

  4. Test responsiveness to confirm that assigned slots fit within the corresponding width for each step.