Crafting inclusive dialogs

Employees organizing a page's layout and dialogs.

Let’s face it; dialogs can be a bit of a double-edged sword. They’re those little windows with promotions, logins, updates, and more. Depending on how they’re created, they can either make your web experience smooth sailing or a bit of a headache. Ensuring that these dialogs are inclusive is a vital step toward making your website truly user-friendly for everyone. In this post, we’ll explore simple ways to create user-friendly dialogs that work with keyboards, have the right attributes, and meet accessibility color standards.

Keyboard-friendly dialogs

Not everyone uses a mouse or touchpad to browse your website. Some people have limited mobility, and others rely on tools like screen readers. To make your dialog windows work for everyone, let’s start by making them easy to navigate with a keyboard.

Tab Key: The TAB key is your customer’s navigation buddy within your dialog. When they press TAB, it should smoothly take them to the next clickable item inside the dialog. The order should follow what they see, moving from top to bottom and left to right.

Shift + Tab: If they want to go back a step, they can use SHIFT + TAB. It allows your customer to effortlessly move to the previous clickable element within the dialog, enhancing the overall user experience.

Esc Key: And for a quick exit, there’s the trusty ESC key. When they hit it, the dialog closes and takes them back to where they started. Essentially retracing the steps that opened the dialog in the first place.

Don’t let users TAB or SHIFT + TAB out of the dialog while it’s open.

Dialog attributes

Attributes not only enhance the experience for all users but are particularly valuable for those relying on screen readers. Let’s explore the attributes your dialogs need and what they signify.

hidden Attribute: The hidden attribute is your behind-the-scenes magician. It conceals your dialog when it’s closed, ensuring that it doesn’t clutter the accessibility tree. The hidden attribute is dynamic, appearing when the dialog is closed and disappearing when it’s open.

role=”dialog”: Adding the role="dialog" attribute labels your dialog, letting assistive technologies know that it’s a distinct element. This helps users understand that they’re interacting with a separate part of the page.

aria-modal=”true”: With aria-modal, it’s like telling assistive tools that the content under the dialog isn’t really part of the dialog itself. This helps keep things clear for users who need assistance.

Darken the background

When your dialog pops up, it should really stand out. It needs to be the main star of the show and catch your customers’ eye. To make this happen, you should darken the content behind your dialog. This darkening does two important things:

  1. Helps People Focus: Some folks with vision problems might have trouble telling what’s in front and what’s in the back, especially with dialogs. Darkening the background makes it clear that the dialog is the main focus.
  2. Makes It Easier to Read: A darker background is like switching on “dark mode”, making the content in your dialog easier to read.

The close button

Don’t forget the trusty close button on your dialog. To make it inclusive, there are a couple of things to keep in mind:

  1. Color Contrast: The colors on the button need to have a good balance. If your close button has text, it needs a 4.5:1 ratio, but if it only has an icon, 3:1 is enough. This makes it easy for people with low vision or color blindness to use the button.
  2. Size Matters: Make sure the close button is at least 24px by 24px. This way, it’s big enough for people to easily tap or click on, making it simple to find and use.

Conclusion

By making your dialogs keyboard-friendly, using the right HTML labels, darkening the background when they appear, and ensuring that close buttons have enough contrast, you’re on your way to creating dialogs that work for everyone on your website. These changes don’t just enhance your website’s reputation and reach – they also contribute to a more inclusive digital world. So, start implementing these accessibility enhancements today and contribute to a more inclusive digital world. Your customers will thank you for it!