#
#
Stylesheet
#
Overview
Pagy includes a few stylesheet files that you can download, link, or copy, and integrate with your app.
You don't need any stylesheets if you use nav tag with :bootstrap
or :bulma
styles.
#
HTML Structure of Nav Bars
To ensure a minimalistic valid output, complete with all the ARIA attributes, pagy outputs a single line with the minimum number of tags and class attributes required to identify all the parts of the nav bars:
- The output of
nav_tag
andnav_js_tag
helpers, is a series ofa
tags inside anav
tag wrapper. - The disabled links are so because they are missing the
href
attributes. - The
pagy nav
andpagy nav-js
classes are assigned to thenav
tag. - The
current
andgap
classes are assigned to the specifica
tags.
Tips
- The stylesheet targets the disabled
a
tags using thepagy a:not([href])
selector. - You can make the
gap
look like the other pages by removing the:not(.gap)
- You can target the previous and next links by using
pagy a:first-child
andpagy a:last-child
pseudo classes
You can easily transform the stylesheet below by editing the content inside the curly brackets, usually leaving everything else untouched.
stylesheet_path = Pagy::ROOT.join('stylesheet/pagy.scss')
pagy.scss
.pagy {
display: flex;
font-family: sans-serif;
font-size: 0.875rem;
line-height: 1.25rem;
font-weight: 600;
color: rgb(107 114 128);
& > :not([hidden]) ~ :not([hidden]) {
--space-reverse: 0;
margin-right: calc(0.25rem * var(--space-reverse));
margin-left: calc(0.25rem * calc(1 - var(--space-reverse)));
}
a:not(.gap) {
display: block;
text-decoration: none;
border-radius: 0.5rem;
background-color: rgb(229 231 235);
padding: 0.25rem 0.75rem;
color: inherit;
&:hover {
background-color: rgb(209 213 219);
}
&:not([href]) { /* disabled links */
cursor: default;
background-color: rgb(243 244 246);
color: rgb(209 213 219);
}
&.current {
background-color: rgb(156 163 175);
color: rgb(255 255 255);
}
}
label {
white-space: nowrap;
display: inline-block;
border-radius: 0.5rem;
background-color: rgb(229 231 235);
padding: 0.125rem 0.75rem;
input {
line-height: 1.5rem;
border-radius: 0.375rem;
border-style: none;
background-color: rgb(243 244 246);
}
}
}
stylesheet_path = Pagy::ROOT.join('stylesheet/pagy.css')
pagy.css
.pagy {
display: flex;
font-family: sans-serif;
font-size: 0.875rem;
line-height: 1.25rem;
font-weight: 600;
color: #6b7280;
}
.pagy > :not([hidden]) ~ :not([hidden]) {
--space-reverse: 0;
margin-right: calc(0.25rem * var(--space-reverse));
margin-left: calc(0.25rem * calc(1 - var(--space-reverse)));
}
.pagy a:not(.gap) {
display: block;
text-decoration: none;
border-radius: 0.5rem;
background-color: #e5e7eb;
padding: 0.25rem 0.75rem;
color: inherit;
}
.pagy a:not(.gap):hover {
background-color: #d1d5db;
}
.pagy a:not(.gap):not([href]) { /* disabled links */
cursor: default;
background-color: #f3f4f6;
color: #d1d5db;
}
.pagy a:not(.gap).current {
background-color: #9ca3af;
color: white;
}
.pagy label {
white-space: nowrap;
display: inline-block;
border-radius: 0.5rem;
background-color: #e5e7eb;
padding: 0.125rem 0.75rem;
}
.pagy label input {
line-height: 1.5rem;
border-radius: 0.375rem;
border-style: none;
background-color: #f3f4f6;
}
stylesheet_path = Pagy::ROOT.join('stylesheet/pagy.tailwind.css')
pagy.tailwind.css
.pagy {
@apply flex space-x-1 font-semibold text-sm text-gray-500;
a:not(.gap) {
@apply block rounded-lg px-3 py-1 bg-gray-200;
&:hover {
@apply bg-gray-300;
}
&:not([href]) { /* disabled links */
@apply text-gray-300 bg-gray-100 cursor-default;
}
&.current {
@apply text-white bg-gray-400;
}
}
label {
@apply inline-block whitespace-nowrap bg-gray-200 rounded-lg px-3 py-0.5;
input {
@apply bg-gray-100 border-none rounded-md;
}
}
}