Scoped navigation inside a sidebar with Turbo Frames

7969
0

Sometimes you want only part of the screen to navigate—like a sidebar list updating the main content. Turbo Frames can do this cleanly: render the sidebar normally, and make its links target a turbo_frame_tag called main. Clicking a link swaps the main content while leaving the sidebar (filters, search) intact. This reduces duplication and makes the UI feel app-like. The key is to ensure the target pages render a matching turbo_frame_tag 'main' wrapper around their content; otherwise Turbo will visit the full page. I also keep a “View full page” link with data-turbo-frame='_top' for users who want standard navigation.