But when changing classes, it’s sometimes best to apply style details conditionally. For example, imagine your view has a pager.
Pagers are often used to navigate larger sets of items.
When navigating, it can be helpful to show the user the page they’re currently on. The style of the item is conditionally set, based on the current page that’s being viewed. A pager in this case may look something like this:. In this example, there are five pages. Only one of these pages is selected at a time.
If you built this pager with Bootstrap, the selected page would have a CSS class named active applied.
You’d want this class applied only if the page was the currently viewed page.
In other words, you’d want to conditionally apply the active CSS class.