Table of Contents
NOTES
PL Breaking changes from BS4 to BS5
AFFECTED COMPONENTS FROM THE BS4-BASED IUX PL:
- Accordion: Data attribute changes; CSS changes needed due to data attribute changes (only if using the plus and minus switch on panels for the BS4?); Difference in plus vs. minus and now BS5 chevrons; Note that the BS5 accordion may still need custom (branding) styling.
- Buttons: Data attribute changes for the Dropdown Button and Kebab Menu dropdown; Note also the active button styling with the bright blue - which may be applied by the browser as now I'm seeing that effect in the BS4 components also; For the Button Groups, the syntax changed for the input type of "radio" and "checkbox" with how the component is coded and the CSS changed also due to the changed HTML which you can see internal on this page - for the JS radio "button" examples, the JS is still needed and works compared to the BS4 examples.
- Modals: Data attribute changes (closing them out via the "Close" button or close icon); Note new XL and fullscreen modals out-of-the-box with BS5
- Dismissable alerts: Data attribute change (closing them out)
- Card with chevron: CSS changes needed for chevron animation behavior; CSS styling needed with margin 0 inline and also .card-footer styling
- Tooltips & Popovers: Data attribute changes
DETAILS ON BREAKING CHANGES:
- Data attributes are now namespaced in BS5 (see https://github.com/twbs/bootstrap/issues/32656)
- Changed all instances of
data-toggle
todata-bs-toggle
- Changed all instances of
data-parent
todata-bs-parent
- Changed all instances of
data-target
todata-bs-target
- Changed all instances of
data-bs-icon
todata-bs-icon
- Changed all instances of
data-prefix
todata-bs-prefix
- Changed all instances of
data-dismiss
todata-bs-dismiss
- For the popovers HTML: Changed all instances of
data-container
todata-bs-container
,data-placement
todata-bs-placement
, anddata-content
todata-bs-conent
- Changed all of the modal buttons to a newer, cleaner BS5 class. Specifically, this
code:
was changed to<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
IDEAS MOVING FORWARD:
- One option is to make a new BS5-based PL with a newly generated stylesheet and stop updating the BS4 one - then, do we find a "new" PL creation site or stay with the current one (with some technical debt with dependency updates)>.
- Another option would be to isolate the CSS that needs to happen for BS5 apps using the BS4 pattern library, and either add that to the main stylesheet (CSS after the "regular" CSS/SASS in the PL files), or have a BS5-specific stylesheet (manually maintained?) with the override styles loaded after the BS4 > IUX PL > BS5 IUX PL.
Accordion
Using the card component, you can extend the default collapse behavior to create an
accordion. To
properly achieve the accordion style, be sure to use .accordion
as a
wrapper.
Also, check the JS tab for an example of a jQuery "scroll to active panel" script, which is a preferred interaction for opened accordion panels (the only exception being accordion used within modals, which should not have this animation).
BS5 Accordion from https://getbootstrap.com/docs/5.0/components/accordion/
ACCORDION - Breaking changes from BS4 to BS5:
- Changed the CSS from
data-toggle
todata-bs-toggle
for changing the plus and minus icons on the panels. Note that the modified CSS is internal on this page. - I had to comment out the "scroll to active panel" script, as that was making the new BS5 accordion not work. We should look into if we need to/should modify the script, when used by an app, to work well with BS5 to offer that same behavior.
- Next steps:
- Possibly make an "Accordion for BS4" and "Accordion for BS5" pages on the PL, with the example code. Then, we can still have the current accordion style and "scroll to active panel" JS, and, style up the BS5 accordion to use for BS5-based projects.
.accordion-body
,
though the transition does limit overflow.
.accordion-body
,
though the transition does limit overflow.
.accordion-body
,
though the transition does limit overflow.
BS4 Accordion Currently in the PL
Alerts
Alert controls retain color palette specified in variables with a few twists. View colors here.
Alerts - Default
Use alerts to show the user a message.
Small Alerts
Use a small alert if you need to put an alert within a card.
Dismissable Alerts
Alerts Bullet List
- This is one line.
- This is the second one..
- And a third.
- This is one line.
- This is the second one..
- And a third.
- This is one line.
- This is the second one..
- And a third.
- This is one line.
- This is the second one..
- And a third.
- This is one line.
- This is the second one..
- And a third.
- This is one line.
- This is the second one..
- And a third.
- This is one line.
- This is the second one..
- And a third.
Alerts - Timeout
Apply a 5-second timeout for alerts without a close. This excludes error messages. (Refresh the page and scroll to this section to see an example.)
Badges
A small count and labeling component.
Default Example
Badges scale to match the size of the immediate parent element by using relative font
sizing and em
units.
Heading 1 Primary
Heading 2 Primary
Heading 3 Primary
Heading 4 Primary
Heading 5 Primary
Heading 6 Primary
Contextual Variations
Add any of the below mentioned modifier classes to change the appearance of a badge. Please note that this is also the default sizing of a badge. This default size would appear when there is no font size defined within the parent element.
Casing Options
Should be the opposite casing of the buttons so that users do not confuse it with a button.
Uppercase
Primary Secondary Success Danger Warning Light DarkLowercase
Primary Secondary Success Danger Warning Light DarkCapitalize
Primary Secondary Success Danger Warning Light DarkDefined Sizes
Add any of the below mentioned modifier classes to set a specific size of a badge.
Small
Primary Secondary Success Danger Warning Light DarkMedium
Primary Secondary Success Danger Warning Light DarkLarge
Primary Secondary Success Danger Warning Light DarkNotifications
Badges can be used as part of links or buttons to provide a counter for notifications.
Use the
.badge-pill
class for notifications.
Breadcrumbs
We prefer using arrows to slashes when creating a breadcrumb.
Buttons
For practical reasons APA applications adhere to Bootstrap's semantic buttons.
Yellow CTA’s should be used sparingly and only for e-commerce layouts. General CTA’s should contrast the background color (blue on white, white on blue).
Responsive ButtonsWe recommend making some buttons full width on mobile devices. You could use the following code within the mobile viewport. You might need to add margin to the top or bottom of the mobile button depending on your layout.
@media only screen and (max-width: 767px) {
.btn-responsive {
width: 100%;
}
}
Core Buttons
Primary - .btn-primary
Outline - .btn-outline
CTA - .btn-cta
Success - .btn-success
Danger - .btn-danger
Outline (Dismiss) - .btn-outline--dismiss
Outline (No Fill) - .btn-outline--no-fill
Text Button - .btn-textbutton
APA Publishing Buttons
Red Squared - Solid - .btn-pubs-1
Blue Squared - Solid - .btn-pubs-2
Purple Squared - Solid - .btn-pubs-3
Red Rounded - Outline - .btn-pubs-4
Blue Rounded - Outline - .btn-pubs-5
Purple Rounded - Outline .btn-pubs-6
Purple Squared - Outline - .btn-pubs-7
Blue Squared - Outline - .btn-pubs-8
Outline (Dismiss, Square Btn Override) - .btn-outline--dismiss
Button Sizes & Types
Large - .btn-lg
Medium - .btn-md
Small - .btn-sm
Icon Left
Icon Right
Dropdown Button
Anchor Tag Button
Button TextAdd New Item Button
Used mostly in forms for users to add new fields or values.
Kebab Menu
Used in menus and menu bars to show additional options. The icon is most often located at the top-right or top-left of the screen or window.
Dropdown Button
Button Group
USAGE: Button groups are used as an alternative for radio buttons, and work well for the UI when you need a more prominent display on the form and a larger tapping target than a radio button component has. Button groups are also commonly used as filter options or acting like "tabs," or for rating scales like the Net Promoter Score (NPS).
An example of a simple button group acting as radio buttons is on the Course Adoption System Request screen, for the Country field when picking either "United States" or "Canada." Here, choosing one of the options controls the "State/Province/Region" select list values.
STYLING: Instead of applying button sizing classes to every button in a
group, just
add
.btn-group-*
to each .btn-group
, including each one when
nesting multiple
groups (all of the demo examples are using .btn-group-sm
except the NPS
demo which is using
the default size). The "primary" style for button
groups is modeled after the .btn-outline
button class, while the
Publications Style is
modeled after
the .btn-pubs-8
button class. Also, if using a button group with labels and
input radio
type components, add .btn-group-toggle
to the div
containing
the button group
to style the <input>
s within your buttons.
RESPONSIVENESS: The amount of buttons and horizontal length of the
button group will
determine the best
approach to
achieve responsiveness. Some options are to convert the button group to a dropdown at
smaller screen
widths, as shown on the Polaris Explore All Notifications mockup for
the sort and
filter buttons. Or, coverting a horizontal display to a vertical display for the button
groups, as shown
on the Polaris Record Views mockup for the Time
Period field. Another
option is to set a min-width
with overflow-x: auto;
for a
container of the
button group to make a horizontal scroll bar appear below a certain screen width.
ACCESSIBILITY: Accessibility elements include a
role="group"
and
aria-label="description of the
button group"
in the .btn-group div
, and
<fieldset>
tags and a
<legend>
which can be
.sr-only
and/or specifying the field as required field using
.sr-only
.
PURE CSS vs. JAVASCRIPT: For checkbox behavior with button groups, no
additional
JavaScript is needed.
If you apply data-toggle="buttons"
to the wrapper element the child buttons
will
automatically have .active
applied to whichever button is clicked. Note
that this
.active
class can be applied to any number of <button>
elements within
the group; if your intention is to make .active
unique with radio button
behavior, you need
to use JavaScript. If you’re pre-toggling a button, you must manually add the
.active
class
and aria-pressed="true"
to the <button>
.
To achieve radio button behavior with button groups, additional JavaScript is needed for the styling of selected/checked buttons when using button components, but not necessary when using labels and input radio type components (e.g., the NPS example in the demo). For certain types of responsive switches with button groups, JavaScript may be needed.
Horizontal Display - Checkbox Behavior with Button Components - All CSS, No Javascript Needed (modeled after .btn-outline) - NOTE: This changed in BS5
Horizontal Display - Radio Button Behavior with Button Components - JavaScript Needed For Radio Button Behavior with Buttons (modeled after .btn-outline)
Vertical Display - Radio Button Behavior with Button Components - JavaScript Needed For Radio Button Behavior with Buttons (modeled after .btn-outline)
Horizontal Display - Radio Button Behavior with Labels and Radio Input Components - All CSS, No Javascript Needed (modeled after .btn-outline) - NOTE: This changed in BS5
PUBLICATIONS STYLE - Horizontal Display - Radio Button Behavior with Button Components - JavaScript Needed For Radio Button Behavior with Buttons (modeled after .btn-pubs-8)
Cards
APA applications adhere to Bootstrap card containers for markup. In general, content cards should always be lighter than their backgrounds (e.g., white cards on light gray backgrounds). Below are a few basic styles:
Card Header: Semantics
When creating cards, be mindful of section heading semantics. Headings communicate the organization of the content on the page. Web browsers, plug-ins, and assistive technologies can use them to provide in-page navigation. For more information, visit W3C's web accessibility tutorials on headings.
H2 Card Header
Text goes here
H3 Card Header
Text goes here
Card with Customization
Card with image cap, card title, subtitle, text, list group, and medium primary button.
Card titles are used by adding.card-title
to a <h*>
tag. In the same way, links are added and
placed next to
each other by adding .card-link
to an <a>
tag.
Subtitles are used by adding a .card-subtitle
to a
<h*>
tag. If the .card-title
and the .card-subtitle
items are placed in a .card-body
item, the card title and subtitle are
aligned nicely.
Card title
Card subtitle
Some quick example text to build on the card title and make up the bulk of the card's content.
- Cras justo odio
- Dapibus ac facilisis in
- Vestibulum at eros
Text goes here
Card with Header and Chevron Expandable Section
Used to hide/show additional content within a card.
Card Title With Chevron
Text goes here
- Cras justo odio
Responsive Card Group
Used for a 4-card row desktop design which goes to 2 cards per row and then 1 card per row, all with rounded corners around all cards based on the breakpoints.
Footer
Apps need a slim minimal footer for all pages which contains a link to APA's Privacy Policy for General Data Protection Regulation (GDPR) compliance.
Sticky Footer
To make the footer stick to the bottom of the page, add a surrounding div with a unique
id around your
content. In this demo, we named the div id #mainBodyContainer
.
Be sure not to wrap the div around the footer.
Here is an example of the markup:
<html>
<head>...</head>
<body>
<div id="mainBodyContainer">
<!-- main content here -->
</div>
<!-- /#mainBodyContainer -->
<footer>
<!-- footer content here -->
</footer>
</body>
</html>
You then want to add this CS for the body and unique ID:
body {
display: flex;
height: 100vh;
flex-direction: column;
}
#mainBodyContainer {
flex: 1 0 auto;
}
Footer - Basic
Here a very minimal footer for web apps.
Forms
General Form Field
APA applications adhere to Bootstrap forms.
Forms are a crucial component of many ITS applications. If you have something that you would like to add to this section, please send us an email at ux-services@apa.org with your feedback.
Below is the general structure for a text field input. The field label should be clear and properly describe the input. Placeholder text should simple and straightforward (Example: "Enter {Field Label Name}"). Also, if needed, provide helper text to help users add the correct input. We generally recommend single column format for all fields except for first and last name. We also recommend using title casing for field labels and placeholders. Helper text should use sentence casing. The following fields are accessible as well.
From W3C: The name attribute specifies the name of an <input>
element.
The name attribute is used to reference elements in a JavaScript, or to reference form
data after a form is submitted. Note: Only form elements with a name attribute will have
their values passed when submitting a form.
Also, autocomplete attributes ("autofill") should be used for input fields when appropriate. See documentation here.
Required & Optional
Required Usage
All required fields should be marked with a red asterisk
The "All fields marked with * are required
" statement (see example in demo) should be displayed at the top of every form with required field asterisks. The statement only needs to be displayed once at the "top" of the screen (e.g., if there are multiple cards with form fields, put the statement on the first/top-most card with fields).
Use an asterisk (*) with the form field label:
<span class="text-danger required-asterisk">*</span>
Add text for a screen reader that a field is required:
<span class="sr-only">required</span>
Provide HTML and ARIA required attributes.
- HTML5:
<input type="text" id="first-name1" name="first-name" required>
- ARIA:
<input type="text" id="first-name2" name="first-name" aria-required="true">
Optional Usage
For optional fields, "(optional)" can be displayed if it makes sense for the specific form/screen (e.g., on the ecommerce redesigns, with the Phone Extension field). If using Optional display instead of Required, include the statement "All fields are required unless marked as Optional" at the top of the form.
When marking an optional field, use <span class="optionalText">(optional)</span>
Circumstances that you can utilize Optional form fields:
- When asking for an address from a user, additional address fields beyond the first can be marked as optional.
- When asking for a user's name and the middle name or initial is optional.
Ideally, a combination of the above methods to mark that fields are required and optional within forms to make it clearest to all users. This will reduce the number of errors when filling out forms and allow a smoother user experience for users.
Email & Password
First Name & Last Name
First Name and Last Name are two input fields which can be placed horizontally.
Address Form Example
To make the first option in the select list be "disabled", which adds an effect similar
to input field placeholder text, use code such as: <option selected="true"
disabled="disabled">Choose section...</option>
For the Country dropdown, put the "United States" select option on the top of the list if
appropriate,
but also include this option alphabetically in the select list. For a horizontal line
separator in the
select list, you can use <option value=""
disabled="disabled">────────</option>
Checkboxes and Radios
Checkboxes allow users to select multiple options, where radio groups allow users to select one option from a group.
Use fieldsets to group related form controls. The first element inside a fieldset must be a legend element which describes the group. Please note that single checkboxes do not need to have fieldsets or legends.
Any general text which is important for filling in the form and cannot be put into a hint, should be in that legend (as shown in the first checkbox group example). But the legend shouldn't be too long either.
Radio Buttons
Single Checkbox
Checkbox Group
Checkbox Group (Hint outside of legend)
Avoid links in legends when possible. Links inside legends are not read by some screen readers, most notably Internet Explorer 11, paired with JAWS. If you need a pattern like this, put the link outside of the legend element, but keep all other useful hint text in the legend. You will need to use the aria-describedby attribute to show the relationship between the legend to the hint.
Other Fields
For certain fields, such as the search input fields, the label can be hidden with
.sr-only
.
Checkbox Toggle
A checkbox toggle is a good solution for minimizing the amount of fields shown at once on the screen. Currently, we are using this toggle on two systems–APA ecommerce screens and Course Adoption System.
Form Validation Example
Here is an example of form validation (using the jQuery Validate library). The Email field here is validated as being required and it needs to be a valid email format.
In most cases, the validation message should include the field label and be written in the following format: Enter your [FIELD LABEL]. In some cases, a top error container should be used in addition to contextually placed error messages.
The cursor should be focused to the top-most invalid field on the page after a form submit.
For fields with errors, we recommend highlighting the input field border red (#a94442)
along with a red
message (#990000) underneath the field. On form submit, successfully validated input
fields should have
a green border (#2a8c3a) with no corresponding message. On focus of valid fields should
have a box
shadow of box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #51cb65;
and
on focus of
invalid fields should have a box shadow of box-shadow: inset 0 1px 1px
rgba(0,0,0,.075),0 0 6px
#ff0000;
Character Count
This character count is modeled after the gov.uk component for accessibility. An example of usage is the Polaris onboarding and preference management forms.
This design allows user input to exceed the maximum characters, but applies an error class to the character count when the input exceeds the maximum allowed characters. This lets users type or copy and paste their full input, then edit it down. In addition to this message, frontend validation should be used to prevent form submission when the input exceeds the maximum allowed characters.
The JavaScript for this component makes the character count work.
Also included in this example is a script making the textarea autogrow based on input.
Headers
Most applications can utilize a simplified header, with a minimalist design of the APA logo or specific app logo, and other elements such as a "cart" button and "log in" button (e.g., the Course Adoption System site).
The APA logo could be replaced with an app-specific logo (with changes to the destination anchor of the logo also). Note there are responsive media queries to resize and switch the logos from horizontal to stacked on smaller devices.
Header - Basic
The most basic, simplified app header, used for pages that focus on a main conversion in the page's body section (e.g., login forms).
Header - Basic with Cart and Log In Buttons
A simplified app header with additional buttons/links, used for apps which need additional top buttons (e.g., to show items in a shopping cart or "log in/log out" links.
Modals
When creating modals, be mindful of section heading semantics. Since modals
sit outside of page,
they should not use a <h1>
but instead start with a
<h2>
.
For an example of an accessible modal, please refer to WAI-ARIA
Authoring Practices.
Modal - Types
Different types of modal designs to be used in different scenarios.
Modal - Sizes
Default (medium), full screen, extra large, large, and small modal sizes, which can be applied to any type of modal. Note there are responsive utilities for the full screen modal.
Timed Modal
An example of a modal that disappears after 5 seconds after being launched. Make sure there is enough time for a user to read the message.
Do Not Show Again Modal with Cookie
This modal example has a checkbox that when checked, sets a cookie to not show the modal again for one day.
Notes
Use a note to highlight important information on the page. This should be used instead of an alert if the message is long or needs to be larger.
Note - .alert-note
How to access your purchase:
To access your APA PsycNET® Direct purchases, click on the product below, or go to your MyPsycNET or MyAPA (http://my.apa.org/portal/) account.
How to access your purchase:
To access your APA PsycNET® Direct purchases, click on the product below, or go to your MyPsycNET or MyAPA (http://my.apa.org/portal/) account.
How to access your purchase:
To access your APA PsycNET® Direct purchases, click on the product below, or go to your MyPsycNET or MyAPA (http://my.apa.org/portal/) account.
- Culturally related risk factors of suicidal
ideation, intent, and behavior
among Asian American women.
Augsberger, A., Rivera, A. M., Hahm, C. T., Lee, Y. A., Choi, Y., & Hahm, H. C. (2018). Asian American Journal of Psychology, 9(4), 252-261. - Qualitative methods in Asian American
psychology.
Nagata, D. K., & Suzuki, L. A. (2017). Asian American Journal of Psychology, 8(4), 259-261.
Note (Light) - .alert-note-light
How to access your purchase:
To access your APA PsycNET® Direct purchases, click on the product below, or go to your MyPsycNET or MyAPA (http://my.apa.org/portal/) account.
How to access your purchase:
To access your APA PsycNET® Direct purchases, click on the product below, or go to your MyPsycNET or MyAPA (http://my.apa.org/portal/) account.
How to access your purchase:
To access your APA PsycNET® Direct purchases, click on the product below, or go to your MyPsycNET or MyAPA (http://my.apa.org/portal/) account.
- Culturally related risk factors of suicidal ideation, intent, and behavior among Asian American women.
Augsberger, A., Rivera, A. M., Hahm, C. T., Lee, Y. A., Choi, Y., & Hahm, H. C. (2018). Asian American Journal of Psychology, 9(4), 252-261. - Qualitative methods in Asian American psychology.
Nagata, D. K., & Suzuki, L. A. (2017). Asian American Journal of Psychology, 8(4), 259-261.
Pagination
Pagination is a user interface pattern that divides content into separate pages. This component is helpful when you have a lot of content to display. For longer pages, place the pagination at the top and bottom of your list of items.
Pagination is good when the user is searching for something specific within the list of results. It also gives the user a sense of control. The numbered pages allows them to reference an item quicker too.
An alternative to pagination is a "Load more" button, where users only have to click one button to load the next set of results. With pagination, the list of results gets replaced whereas the "Load More" button adds to the list. Using the one button is ideal when users want to browse and compare items within a list.
Accessibility notes: Pages likely have more than one such navigation
section. Provide a descriptive aria-label
for the <nav>
to reflect its purpose. For example, if
the pagination component is used to
navigate between a set of search results, an appropriate label could be
aria-label="Search results pages"
. Also, provide HTML for
screenreaders to show the active/current page, such as
<li class="page-item active" aria-current="page"><span
class="page-link">1<span
class="sr-only">(current)</span></span></li>
Here is an example that has active and disabled states.
We recommend swapping out active or disabled anchors for
<span>
to remove
click functionality and prevent keyboard focus while retaining intended
styles.
Working with Icons
When adding icons instead of text to pagination, provide proper screen
reader support with aria
attributes and the
.sr-only
utility.
Large Data Sets
For large data sets, we recommend showing the first and last page number and then truncating the pagination with ellipses. To help the user quickly navigate through the list, add start start and end along with previous and next.
Responsiveness note: Consider the horizontal length of your pagination on mobile so that it is able to fit inside a smaller breakpoint.
Demo
Progress Meter
A simple progress meter used on several apps (e.g., ecommerce screens, CAS). Note the progress labels are not shown <760px.
- 1Search
- 2Request
- 3Review
- 4Thanks
Tags
Tags utilize the same coding as Badges, with the addition of an
accessible "close" button
similar to Modals. See the Badges page for
variations for casing and sizes, although note that the
line-height
style and other
styles may need
to be changed for different tag sizes.
Extra JavaScript is needed for the closing/fadeout of the tags.
Contextual Variations - Badge Style
Contextual Variations - Badge Pill Style
Primary Tags Style
Publications Tags Style (modeled after .btn-pubs-2)
Tooltips & Popovers
Tooltips
Tooltips can be used as a way to show short, non-critical information to the user. They are meant to clarify or help you use the content that they hover over, not add additional content. For a short sentence or less message to the user, use a tooltip.
Since tooltips are only meant to tell the purpose of an element, they should be short and to the point (e.g., "Click X to do X" or "User post count").
Tooltips are typically only visible on hover. So, if you need to be able to read the content while interacting with other parts of the page, then a tooltip will not work and you should consider using a popover.
For icons, we are using the question mark icon for tooltips.
Example Tooltip with Icon
Popovers
Popovers are meant to give related additional content. A popover is used to embed a longer note into a tag; by default they are activated by clicking on the tag (text and/or icon).
Popovers can be much more verbose than tooltips, and can include a header and many lines of text in the body. If HTML is needed in the message, the message is multiple sentences/lines of text, or if you want both a heading and text in the message, use a popover.
Popovers are typically dismissable, whether by clicking outside of the popover, a close button on the popover, or clicking again on the popover text/icon (depending on implementation). For that reason, you can set up a popover to allow you to interact with other elements on the page while still being able to read its content. On top of that, since popovers will remain open when mousing out of their target, you can add additional buttons or interactions within them.
For icons, we are using the info icon for popovers.
Example Popover with Icon