Utility classes for spacing, layout, type, and more, built on our design tokens.
Utility classes let you apply common styles directly in your markup. They are built on our tokens, so anything you compose with them stays consistent with the system.
To use them, add the Design System to your project and apply the classes below.
Apply .pl-reset to reduce browser inconsistencies in things like default line heights, margins and font sizes of headings.
Applying .pl-typeset to a containing element will style all of its children text elements which can be useful for laying out typographic foundations.
<div class="pl-reset pl-typeset pl-margin-l">
<h1>Heading level 1</h1>
<h2>Heading level 2</h1>
<h3>Heading level 3</h1>
<p>Paragraphs are usually represented in visual media as blocks of text separated from adjacent blocks by blank lines and/or first-line indentation, but <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/p">HTML paragraphs</a> can be any structural grouping of related content.</p>
</div>
Use .pl-margin-{size} or .pl-padding-{size} to set spacing on all sides of an element.
Available sizes include 0, 2xs, xs, s, m, l, xl, 2xl, and 3xl.
You can also specify the direction .pl-padding-{direction}-{size} using the following prefixes:
b for bottomt for topx for left and righty for top and bottoml for leftr for rightFor the value behind each size, or to use spacing directly in your own CSS, see Tokens.
Use display utility classes to control how elements are rendered.
.pl-block.pl-inline.pl-inline-block.pl-flex.pl-inline-flex.pl-grid.pl-inline-grid.pl-noneUse flex direction utility classes to control the direction of flex items within a flex container. Switch between horizontal (row) and vertical (column) layouts with .pl-flex-row and .pl-flex-col.
Use .pl-gap-{size} to add consistent spacing between direct children of a flex or grid container. This utility is especially useful for layouts using CSS Flexbox or Grid, where you want to control the space between items without adding margin classes to each child.
Available sizes include: 0, 2xs, xs, s, m, l, xl, 2xl, and 3xl.
Use .pl-border-radius to apply a standard border radius to an element, or .pl-border-radius-subtle for a more subtle rounding. These utilities help you quickly round the corners of boxes, cards, images, and other elements.
<style>
.border-radius-example {
display: inline-block;
background: var(--pl-color-bg-info);
padding: var(--pl-space-2xs) var(--pl-space-m);
border: solid 1px var(--pl-color-fg-info);
color: var(--pl-color-fg-info);
}
</style>
<div class="pl-reset pl-typeset pl-margin-l pl-flex pl-gap-m">
<span class="border-radius-example pl-border-radius">Penn Libraries</span>
<span class="border-radius-example pl-border-radius-subtle">Penn Libraries</span>
</div>
For the value behind each radius, or to use them directly in your own CSS, see Tokens.
Use .pl-caps for a small uppercase label, or .pl-caps--subtle for a quieter version. These work well for section labels, table headers, and short bits of text that introduce a heading or a group.
<div class="pl-reset pl-typeset pl-margin-l pl-flex pl-flex-col pl-gap-2xs">
<span class="pl-caps">New this month</span>
<span class="pl-caps--subtle">New this month</span>
</div>
Use .pl-line-length to set a comfortable maximum line width for readable text. This utility is especially useful for paragraphs, article content, or any block of text where you want to improve legibility by preventing lines from becoming too long.
<div class="pl-reset pl-typeset pl-margin-l pl-flex pl-flex-col pl-gap-m">
<p>
Paragraphs are usually represented in visual media as blocks of text separated from adjacent blocks by blank lines and/or first-line indentation, but HTML paragraphs can be any structural grouping of related content.
</p>
<p class="pl-line-length">
Paragraphs are usually represented in visual media as blocks of text separated from adjacent blocks by blank lines and/or first-line indentation, but HTML paragraphs can be any structural grouping of related content.
</p>
</div>
Focusable elements like links, buttons, form controls, <summary>, and anything with a tabindex automatically receive a visible focus ring when reached with the keyboard. Try tabbing through the example below.
<div class="pl-reset pl-typeset pl-margin-l pl-flex pl-gap-m">
<button class="pl-button pl-button--accent">Focus me</button>
<a href="#">Or focus me</a>
</div>
To give a custom component the same focus ring, apply the --pl-focus-box-shadow token to its :focus-visible state. See Tokens.