<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Nothing</title>
    <description>The latest articles on Forem by Nothing (@nothing).</description>
    <link>https://forem.com/nothing</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F434%2F3fedc269-9ae5-48ed-9508-a24c72719aa8.png</url>
      <title>Forem: Nothing</title>
      <link>https://forem.com/nothing</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/nothing"/>
    <language>en</language>
    <item>
      <title>5 code improvements you can apply today to make your website more accessible</title>
      <dc:creator>René Stalder</dc:creator>
      <pubDate>Fri, 04 Jan 2019 15:37:56 +0000</pubDate>
      <link>https://forem.com/nothing/5-code-improvements-you-can-apply-today-to-make-your-website-more-accessible-27h5</link>
      <guid>https://forem.com/nothing/5-code-improvements-you-can-apply-today-to-make-your-website-more-accessible-27h5</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Mkd4GwsF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ArpI2fzRm4bMO1gQi1bkAAg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Mkd4GwsF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ArpI2fzRm4bMO1gQi1bkAAg.png" alt="" width="880" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If there is a component in web development that is too often treated as an option only (if at all), it’s accessibility. Companies want business value out of it but don’t see a benefit; developers have either never heard of accessibility for the web or think that they can’t apply accessibility in their company due to lack of time.&lt;/p&gt;

&lt;p&gt;In my experience, accessibility for websites and web applications is 80% writing standard compliant HTML markup with progressive enhancement in mind and 20% content improvements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The 80% should be doable by every front-end developer&lt;/strong&gt; with fundamental knowledge in HTML, CSS and JavaScript. This is about semantics, using the right HTML elements, applying correct keyboard focus order and so on. A big part of this work can automatically be tested with tools like &lt;a href="https://github.com/dequelabs/axe-core"&gt;aXe&lt;/a&gt; (the same engine that powers Google’s Lighthouse accessibility tests).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The last 20%&lt;/strong&gt;  — and that’s why I call it content improvements — is a lot of “accessibility by usability”. It’s less technical and more about how you provide the content of your website so that everyone understands it. This is about providing additional hints for screen readers, subtitles in videos, making content readable in high contrast mode or replacing PDFs with web pages (or replacing them with accessible PDFs).&lt;/p&gt;

&lt;p&gt;And, of course, design is also a big part of web accessibility. In this post, I want to show developers five code improvements they can apply today to make their website more accessible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; I might link to various chapters of the &lt;a href="https://www.accessibility-developer-guide.com/"&gt;Accessibility Developer Guide&lt;/a&gt; in this post. Not because the company I’m working for is contributing to the guide but because it provides a more detailed explanation of the materials in this post that are actually tested, verified and kept up-to-date. They are also much easier to understand compared to the official WCAG specification.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before we begin: Fundamental mindset about HTML and CSS
&lt;/h2&gt;

&lt;p&gt;It’s important that you approach HTML and CSS separate. It’s totally fine to use an &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; element in code and then style it like a button. Your HTML markup should make sense on its own, without the styling. That’s why libraries like Twitter’s Bootstrap provide &lt;a href="https://getbootstrap.com/docs/4.2/content/typography/"&gt;classes for various typographic choices&lt;/a&gt; in addition to the default element styling. I recommend using classes as much as possible over &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Type_selectors"&gt;type selector&lt;/a&gt; styling. Your life will be much easier later on, I promise.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iW4Z7WGi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/433/1%2Aq8A54Uhi25YIFE8K7esjMQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iW4Z7WGi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/433/1%2Aq8A54Uhi25YIFE8K7esjMQ.png" alt="Screenshot of the heading classes in the Twitter Bootstrap 4 documentation" width="433" height="455"&gt;&lt;/a&gt;Twitter’s Bootstrap provides additional classes to elements other than H1 to H6 with the exact same styles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nr. 1 — Fix general code semantics
&lt;/h2&gt;

&lt;p&gt;Semantics refers to the &lt;em&gt;meaning of a piece of code&lt;/em&gt;. MDN — which is my favorite source to look up various features of the web platform — &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Semantics"&gt;has a very good description&lt;/a&gt; of what it means for HTML, CSS and JavaScript to be “semantic” (I recommend to quickly read through the referenced page).&lt;/p&gt;

&lt;p&gt;The most frequent case of wrong semantics I’ve come across on websites and applications — especially when frameworks like React, Vue.js or Angular are used — is the misuse of &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; elements for everything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s a short list of cases to check on your website or application:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Titles&lt;/strong&gt; are wrapped in H1 to H6 tags. That doesn’t mean every title needs to be a heading element. Think of writing a text document e.g. in Microsoft Word. When would you style a line of text as a title? When would you make something bold? Just be aware that people using screen readers love to use the H1 to H6 tags to jump around your content. By contrast, boldness of a text, even when marked with a &lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt; tag, doesn’t have any influence on how the screen reader accesses and reads your content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lists&lt;/strong&gt; , no matter if it’s a list of navigation items or a list like this one here, are defined as &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ul"&gt;unordered lists&lt;/a&gt;, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ol"&gt;ordered lists&lt;/a&gt; or &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dl"&gt;description lists&lt;/a&gt;. Make sure there is no list with only &lt;em&gt;one&lt;/em&gt; element. For example, if your navigation can have only one element in any circumstances, remove the list wrappers. Lists with only one element can be confusing to people using screen readers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interactive elements&lt;/strong&gt; are either &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a"&gt;anchors&lt;/a&gt; (&lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;), &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button"&gt;buttons&lt;/a&gt; (&lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt;) or form elements (e.g. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input"&gt;&lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select"&gt;&lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt;&lt;/a&gt;). If you find things like click handlers on elements like a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, that element most likely should be one of the elements above.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use the&lt;/strong&gt; &lt;a href="https://dequeuniversity.com/assets/html/jquery-summit/html5/slides/landmarks.html"&gt;&lt;strong&gt;HTML5 section elements in combination with ARIA landmarks&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;to mark content.&lt;/strong&gt; Not all have an effect on screen readers but some have. See the referenced page for a good explanation and how to implement.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s for sure not all you can do, but these are the most common cases of wrong semantics I’ve found in accessibility testings. A more detailed explanation with examples can be found in the &lt;a href="https://www.accessibility-developer-guide.com/knowledge/semantics/"&gt;Accessibility Developer Guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nr. 2 — Fix your title structure
&lt;/h2&gt;

&lt;p&gt;Even if you have all your titles wrapped in correct H1 to H6 elements, that doesn’t automatically mean that they are used correctly.&lt;/p&gt;

&lt;p&gt;Check that there are no heading level gaps: e.g. a &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; has to follow a &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;, a &lt;code&gt;&amp;lt;h3&amp;gt;&lt;/code&gt; has to follow a &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; and so on. For example, if you find a lonely &lt;code&gt;&amp;lt;h5&amp;gt;&lt;/code&gt;, no &lt;code&gt;&amp;lt;h4&amp;gt;&lt;/code&gt; but only &lt;code&gt;&amp;lt;h3&amp;gt;&lt;/code&gt; elements, something’s wrong. So you would rewrite your &lt;code&gt;&amp;lt;h5&amp;gt;&lt;/code&gt; to a &lt;code&gt;&amp;lt;h4&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There is a &lt;a href="https://www.accessibility-developer-guide.com/setup/browsers/bookmarklets/h123/"&gt;bookmarklet&lt;/a&gt; that helps you to find these problems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oGPwpOgL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/448/1%2ATopnw0q77zlTLzk9FkzdJg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oGPwpOgL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/448/1%2ATopnw0q77zlTLzk9FkzdJg.png" alt="Screenshot of h123 Browser Bookmarklet output" width="448" height="825"&gt;&lt;/a&gt;h123 bookmarklet output for &lt;a href="https://gov.uk"&gt;gov.uk&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reminder:&lt;/strong&gt; The visual representation of an element can be different from its HTML element. You can style a &lt;code&gt;&amp;lt;h5&amp;gt;&lt;/code&gt; like a &lt;code&gt;&amp;lt;h4&amp;gt;&lt;/code&gt; by adding a CSS class. And that’s what you should do in the case described above.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nr. 3 — Add hidden titles to the structure to mark site sections for screen readers
&lt;/h2&gt;

&lt;p&gt;This improvement belongs to the 20% mentioned at the beginning of this post: This is not something an automatic testing suite will tell you. These are the additional content improvements you either tackle based on feedback from manual testings or by gut feeling. And with gut feeling I mean:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What’s obvious when the website is visually represented but not so obvious when looking at the HTML markup.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The meaning of &lt;em&gt;hidden titles&lt;/em&gt; is &lt;strong&gt;titles that are not visible by eye but can be accessed by a screen reader&lt;/strong&gt;. This means adding titles like “Main site navigation”, “Language switcher” and “Site footer” to your content.&lt;/p&gt;

&lt;p&gt;Taking again the example of gov.uk like in Nr. 2, you’ll see for example a hidden title for the links in the footer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AXL-nYw6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/431/1%2AgvuY95Zv3iW7NkQKNvNTpw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AXL-nYw6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/431/1%2AgvuY95Zv3iW7NkQKNvNTpw.png" alt="Screenshot of h123 browser bookmarklet output for gov.uk" width="431" height="132"&gt;&lt;/a&gt;Part of the h123 bookmarklet output of gov.uk with “Mark visually hidden” option activated. &amp;lt;h2&amp;gt; “Support links” is marked as visually hidden.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--az6UiE1f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AxLSliPq9LmZuTUDFzuifTw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--az6UiE1f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AxLSliPq9LmZuTUDFzuifTw.png" alt="Screenshot of gov.uk footer section" width="800" height="707"&gt;&lt;/a&gt;Screenshot of the footer of gov.uk, showing that the &amp;lt;h2&amp;gt; for “Support links” is visually hidden.&lt;/p&gt;

&lt;p&gt;The section about headings in the &lt;a href="https://www.accessibility-developer-guide.com/examples/headings/visually-hidden-headings/"&gt;Accessibility Developer Guide&lt;/a&gt; covers this quite well.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Hint:&lt;/em&gt; You and I might not agree about &lt;a href="https://www.accessibility-developer-guide.com/examples/headings/multiple-h1-okay-for-seo/"&gt;using multiple &lt;em&gt;&lt;h1&gt;&lt;/h1&gt;&lt;/em&gt; to improve accessibility&lt;/a&gt;, as gov.uk proofs that you can mostly follow the HTML specification without any accessibility concerns. I for one use the approach of one &lt;em&gt;&lt;h1&gt;&lt;/h1&gt;&lt;/em&gt; and I would recommend this to follow best practice in all projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nr. 4 — Fix your forms
&lt;/h2&gt;

&lt;p&gt;There are more things that can go wrong with forms than I initially thought, before I dove into accessibility. This is not mentioned in Nr. 1 of this post as it’s not only about semantics. There are a few additional things that have to be done to make forms, especially the validations, accessible.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check that every input, select or text area has a&lt;/strong&gt; &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label"&gt;&lt;strong&gt;label&lt;/strong&gt;&lt;/a&gt;: If it doesn’t have a &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt;, what a form field is about is most likely invisible to screen reader users. You can either wrap the form field into the &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt; tag, which is valid, but for more flexibility I recommend using the for attribute to make the connection to a form field via the ID.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mark required fields with the&lt;/strong&gt;  &lt;strong&gt;required attribute&lt;/strong&gt; : This makes it obvious to screen readers that the field is required.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Connect inline validation errors and other hints with&lt;/strong&gt;  &lt;strong&gt;aria-describedby&lt;/strong&gt; : Assuming you show errors just below the form field that contains the mistake, the screen reader doesn’t read the error message when having focus on the field. For this, you need to connect the most likely &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag containing the error message with the form field by adding an &lt;code&gt;aria-describedby&lt;/code&gt; to the form field linking to the ID of the error message. A detailed description can be found in the &lt;a href="https://www.accessibility-developer-guide.com/examples/forms/validation-messages/"&gt;Accessibility Developer Guide&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There are &lt;a href="https://www.accessibility-developer-guide.com/examples/forms/"&gt;a lot more improvements to forms&lt;/a&gt; you probably want to do, but they can also get more complex.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nr. 5 — Fix keyboard focus visibility and order
&lt;/h2&gt;

&lt;p&gt;This is easy to test. Open your website or application and navigate through it without using the mouse (Tabulator key, Shift+Tabular and arrows are your friends, but &lt;a href="https://www.accessibility-developer-guide.com/knowledge/keyboard-only/controlling-a-computer/"&gt;there are more&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Do you always see where you currently are? Can you focus all interactive elements? Does the order make sense to you?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fixes you can apply:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Change source order of elements:&lt;/strong&gt; Default keyboard focus relies on HTML source order. So there can be cases where you want to correct the order in your code and then visually change the order with CSS so it fits in your design. This is totally valid as long as the focus doesn’t make huge jumps from left to right or from top to bottom and back, which can be very confusing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Change the default focus style to something more visible:&lt;/strong&gt; Browsers implement the default focus style very differently. Some browsers show a blue outline when an element is focused. That’s okay on a white background but not on a blue background. Some browsers like Firefox only show a dashed/dotted line around focused elements which is barely visible. &lt;a href="http://adrianroselli.com/2017/02/avoid-default-browser-focus-styles.html"&gt;Never rely on the default focus style&lt;/a&gt;. &lt;a href="https://css-tricks.com/focusing-on-focus-styles/"&gt;Create your own&lt;/a&gt;. For the latest browsers, there is now even a &lt;a href="https://css-tricks.com/keyboard-only-focus-styles/"&gt;modifier for keyboard-only focus&lt;/a&gt;, so you can make a difference between focusing via mouse click and keyboard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use native HTML elements over customization:&lt;/strong&gt; For example, if you want to have &lt;a href="https://www.w3.org/WAI/tutorials/forms/custom-controls/"&gt;custom styles for your radio buttons&lt;/a&gt;, use the &lt;code&gt;&amp;lt;input type=“radio”&amp;gt;&lt;/code&gt; element and overwrite the styles e.g. by visually hiding the input and keeping the label in place with a “fake” styling for the input.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CxDuqx3X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/639/1%2AVcnWBrlaKWQhdJjVB3lAwA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CxDuqx3X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/639/1%2AVcnWBrlaKWQhdJjVB3lAwA.png" alt="Screenshot of focused form field on gov.uk" width="639" height="577"&gt;&lt;/a&gt;Custom focus style for form fields on gov.uk&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Basic accessibility on a website or application isn’t that difficult to achieve. The more modern your UX and design becomes, the more effort is needed to make it accessible, for example when you go with SPA solutions like React, Vue.js or Angular.&lt;/p&gt;

&lt;p&gt;These five fixes are only a few of many you can do, but you should be able to apply them in a couple of hours and already make a big difference.&lt;/p&gt;

&lt;p&gt;If you’re interested in more in-depth knowledge about how to make your websites and applications accessible, I’ve got some links for you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.accessibility-developer-guide.com/"&gt;&lt;strong&gt;Accessibility Developer Guide&lt;/strong&gt;&lt;/a&gt;
A guide mostly for front-end developers on how to build and test websites for accessibility. Includes much practical knowledge from real world testings.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://inclusive-components.design/"&gt;&lt;strong&gt;Inclusive Components&lt;/strong&gt;&lt;/a&gt;
A blog about building accessible components.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.w3.org/WAI/standards-guidelines/wcag/"&gt;&lt;strong&gt;WCAG&lt;/strong&gt;&lt;/a&gt;
The de facto standard for web accessibility.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://alistapart.com/topic/accessibility"&gt;&lt;strong&gt;A List Apart, topic accessibility&lt;/strong&gt;&lt;/a&gt;
Many useful resources about accessibility.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have questions regarding accessibility, feel free to contact me at &lt;a href="//mailto:rey@nothing.ch"&gt;rey@nothing.ch&lt;/a&gt;.&lt;/p&gt;




</description>
      <category>css</category>
      <category>a11y</category>
      <category>html</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Design Systems: Maintaining design with Pattern Libraries</title>
      <dc:creator>René Stalder</dc:creator>
      <pubDate>Thu, 18 Oct 2018 06:50:15 +0000</pubDate>
      <link>https://forem.com/nothing/design-systems-maintaining-design-with-pattern-libraries-1e70</link>
      <guid>https://forem.com/nothing/design-systems-maintaining-design-with-pattern-libraries-1e70</guid>
      <description>

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1aF6Yusq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/k0t581zg59095foymshy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1aF6Yusq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/k0t581zg59095foymshy.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The web is an incredible platform for building software: You can access a ton of information from nearly everywhere and it gives developers a big range to build nearly everything — from simple static websites to 3D games. You might be surprised, but one of the most challenging parts of maintaining software is keeping design and code synchronised with each other. In this post, I want to highlight how we use pattern libraries to maintain a smooth workflow between design and code while developing medium to large web applications.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The term “Design System” is more trending than ever. Since Google’s &lt;a href="https://material.io/"&gt;Material Design&lt;/a&gt; and several other &lt;a href="https://designsystemsrepo.com/design-systems/"&gt;big companies sharing their design system&lt;/a&gt; to the public, the debate around how design is maintained opened up &lt;a href="https://www.designsystems.com/"&gt;all over the internet&lt;/a&gt;. If you never heard of the term, &lt;a href="https://medium.muz.li/what-is-a-design-system-1e43d19e7696"&gt;here’s a good article that explains what a design system is&lt;/a&gt;. In short:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Design systems is a design guide that benefits software, communications, people, and businesses.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One important part of design systems are so-called pattern libraries. While a design system defines a whole design in terms of animation and motion design, content principles, accessibility and information architecture — including the pattern library —  &lt;strong&gt;the pattern library alone defines the components of a design system&lt;/strong&gt; and how they are connected.&lt;/p&gt;

&lt;p&gt;In this way, pattern libraries help to isolate individual elements of a design while providing a platform to keep an overview of all parts. &lt;strong&gt;This is crucial in keeping a design consistent over time&lt;/strong&gt;. For instance: In a web application, a pattern library is a set of HTML elements with corresponding styles and functionality — one of them might be a confirmation dialog that closes when pressing the “Continue” button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KKmqA3us--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ALfuaz7wObeRrxLi7WOI2NA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KKmqA3us--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ALfuaz7wObeRrxLi7WOI2NA.png" alt="Screenshot of a material design dialog"&gt;&lt;/a&gt;The dialog component in the &lt;a href="https://material.io/develop/web/components/dialogs/"&gt;Material Style guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Four reasons to use pattern libraries&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let’s look at four reasons why pattern libraries are an important of design systems and will help you with your project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Consistency&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Pattern libraries might not be worth the investment for small, individual websites. But for web applications that will grow over time and have to be maintained during several years, a pattern library helps to keep the design consistent. Moreover, it &lt;strong&gt;provides the needed overview over what parts of the design are available in code form&lt;/strong&gt; and prevent developers repeating themselves and losing time and focus.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Handling dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A pattern library helps the developer think about the isolation of individual parts of a website. In this way, &lt;strong&gt;unneeded dependencies can be prevented&lt;/strong&gt;. One of the most common mistakes in styling web applications is that new features start to borrow code of other features. In a later stage of extending or changing the web application this often leads to problems by unintentionally changing or breaking parts of the application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Build once, apply everywhere&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A common rule for a pattern library is to &lt;a href="http://bradfrost.com/blog/post/managing-technology-agnostic-design-systems/"&gt;keep it tech-agnostic&lt;/a&gt;. This means that no matter what framework or tool you’re using to build the web application, &lt;strong&gt;the pattern library is kept in a raw format&lt;/strong&gt; whenever possible — e.g. HTML, CSS and JavaScript.&lt;/p&gt;

&lt;p&gt;A raw pattern library can easily be applied to whatever tech stack is used to build the final web application. For example, if you decide to switch the tech stack at a later stage to improve performance or maintainability, you’ll need less time to apply the design to the new stack because you don’t have to rewrite all the parts for the new stack. Additionally, making the pattern library tech agnostic &lt;strong&gt;helps developers which aren’t directly working on front-end&lt;/strong&gt;. They can easily apply the design to other systems without needing to dig into all parts of the front-end code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Provide designers a platform to test&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Pattern libraries provide an easy way for designers to test whether the coded design is aligned with their concept or not. The reason is that it delivers &lt;strong&gt;a simple platform that isolates and displays the finished components&lt;/strong&gt;  — either individually or in combination with other elements and components. Last but not least it can also be used as a solution for automatic testing of individual components outside of the final web application.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The biggest mistake that happens within design systems and pattern libraries probably is that they aren’t maintained.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Looking at a concrete example&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;At Nothing Interactive, we’ve built several pattern libraries over the last couple of years. One of the biggest so far was used for the user interface we designed and developed for &lt;a href="https://www.klett.ch"&gt;&lt;strong&gt;Klett und Balmer Verlag&lt;/strong&gt;&lt;/a&gt;. Klett und Balmer Verlag is one of the biggest educational publishing companies operating in Switzerland. They provide books for schools and individuals. Together with &lt;a href="https://www.h2g.ch"&gt;H2G Internetagentur&lt;/a&gt; , who were responsible for the back-ends, we redesigned the existing experience and are currently working on implementing the new design. &lt;strong&gt;Let’s see how we made use of a pattern librar&lt;/strong&gt; y.&lt;/p&gt;

&lt;p&gt;First of all, their web services are split up into three individual platforms. All together, they comprise klett.ch:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Web shop&lt;/strong&gt; : Provides all the products to buy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User section&lt;/strong&gt; : User settings and options.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Web site&lt;/strong&gt; : Information and articles.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All those sections might use different technologies in the background. Additionally, they connect to different data sources and are managed by different people. But they have one thing in common: They all belong to the Klett und Balmer Verlag and therefore &lt;strong&gt;share many aspects of the design&lt;/strong&gt;. Designing and developing the new user interface without actually providing any back-end logic created several implicit requirements:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Provide the front-end in a form which the back-end developers can easily apply to their stack.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Maintain a single code source for the user interface.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Allow easy integration into the back-end system when changes are made to the UI.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The last requirement is an especially tricky one when you want to use a tech-agnostic approach. Let’s see how we managed it.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The tools: Zeplin + Pattern Lab&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In a first step the designers prepared their design to be provided via &lt;a href="https://zeplin.io"&gt;Zeplin&lt;/a&gt;, an online service that allows to &lt;strong&gt;synchronise the design source&lt;/strong&gt; files with a little helper tool installed on the computer. The screens and components the designer created — for instance in Sketch — are then visible online and allow the developer to interact with them; e.g. by copying out CSS styles or see measurements of specific elements.&lt;/p&gt;

&lt;p&gt;The transformation to code is then done by the developers. They build the components and specific patterns in HTML, CSS and JavaScript by using a pattern library tool. &lt;strong&gt;There are plenty of options to create pattern libraries.&lt;/strong&gt; However, many of them restrict the developers to specific rules: for instance a given folder structure or a templating engine that has to be used.&lt;/p&gt;

&lt;p&gt;Years ago we decided to use &lt;a href="https://patternlab.io"&gt;Pattern Lab&lt;/a&gt;, a tool which helps with the creation of pattern libraries for the web. Pattern Lab is brought to life by &lt;a href="https://www.brianmuenzenmeyer.com/"&gt;Brian Muenzenmeyer&lt;/a&gt;, &lt;a href="http://www.evanlovely.com"&gt;Evan Lovely&lt;/a&gt;, &lt;a href="http://bradfrost.com/"&gt;Brad Frost&lt;/a&gt;, and a team of amazing developers from around the world. It’s one of the longest existing solutions. So &lt;strong&gt;you can trust that it’s very well tested&lt;/strong&gt; for productive use.&lt;/p&gt;

&lt;p&gt;Another good thing about Pattern Lab is: &lt;strong&gt;It gives us a lot of freedom&lt;/strong&gt; on how we want to structure and build our pattern libraries. Different templating engines like &lt;a href="http://mustache.github.io/"&gt;Mustache&lt;/a&gt; and &lt;a href="https://twig.symfony.com/"&gt;Twig&lt;/a&gt; are provided and it will allow &lt;a href="http://handlebarsjs.com/"&gt;Handelbars&lt;/a&gt; in the future.&lt;/p&gt;

&lt;p&gt;At the same time, the back-end team of H2G Internetagentur decided to work with &lt;a href="https://symfony.com"&gt;Symfony&lt;/a&gt;. Luckily, some of the dependencies, most importantly the CMS of the website, are working well with Twig. This made the decision easy to use the Twig edition of Pattern Lab and try to build components that can — in the best case — be directly used in the Symfony environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Gt5hl7DE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/926/1%2ADRzfWdzXI43PrTetLS1Dmw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Gt5hl7DE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/926/1%2ADRzfWdzXI43PrTetLS1Dmw.png" alt="Visualization of the tools and connections"&gt;&lt;/a&gt;From static design to dynamic code: We use Sketch for creating the design and Zeplin as bridge between designers and developers.&lt;/p&gt;

&lt;p&gt;It’s true that this combination doesn’t fully realise the ideal of a tech-agnostic build of the pattern library. But it very much &lt;strong&gt;improves the already mentioned third requirement of the specific project&lt;/strong&gt; for Klett und Balmer Verlag. Most importantly, it solves problems which occur during updates and requires the back-end developers to make changes on the markup. This again allows us to fix issues directly and apply that code to the test environment without further code interaction of the back-end developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Build the pattern library: From the smallest to the biggest piece&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;While the creators of Pattern Lab often refer to &lt;a href="http://bradfrost.com/blog/post/atomic-web-design/"&gt;atomic design&lt;/a&gt;, we decided to use a similar, but slightly different approach. We separated our code into the following sections:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Components&lt;/strong&gt; : A single component like a button or a form field. It can also combine be combined with other components like a dialog containing buttons.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Patterns&lt;/strong&gt; : These are specific use cases where multiple components are combined e.g. a login form, header navigation or the footer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Templates/Layouts&lt;/strong&gt; : Once we combine different patterns like the navigation, the site header and the site footer we get a template. In our case, we used different templates for the shop and the website.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Theme&lt;/strong&gt; : Applying brand specific definitions like colours and fonts. In this layer, we mostly overwrite variables that are used in components and patterns. Without this layer, the components and patterns still work, but have a generic look.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--phLLvjPj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AWQ-iOJZbzsVSF3D_qGDiIA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--phLLvjPj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AWQ-iOJZbzsVSF3D_qGDiIA.png" alt="Screenshot of a rendered output with marked areas of the previously described structure"&gt;&lt;/a&gt;See the different sections in action.&lt;/p&gt;

&lt;p&gt;Last but not least we have a so-called utility section in our pattern library. This mostly contains examples for shared JavaScript interactions like expanding and collapsing an element. It also contains CSS classes for accessibility.&lt;/p&gt;

&lt;p&gt;Once we’re set up like this, we’re able to build our components — disregarding some additional compiling tasks like TypeScript and PostCSS. I won’t go into too much detail here. Basically, we’re able to build our components by adding a Twig template file, a CSS file, a markdown file for documentation and a JSON file for example data. &lt;strong&gt;This delivers a nice and easy to use HTML documentation that can be shared with designers and other developers&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Delivering the pattern library to partners and customers&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Pattern Lab generates an HTML output which can be used to explore and test components. The good part is that it generates raw HTML. Thus, &lt;strong&gt;the whole documentation can be zipped and sent to other parties without any need of setting up a server to use it&lt;/strong&gt;. In our case, we still host the built version of the pattern library on a test environment while delivering the documentation in a ZIP with every release at the same time.&lt;/p&gt;

&lt;p&gt;This was also an important part within this particular project. Remember, we decided early on to use Twig. This would help the back-end developers to directly use the components. Luckily, this worked out very well in the end. What we then delivered to the back-end developers was:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The raw Twig files from our source code&lt;/li&gt;
&lt;li&gt;Processed and minified CSS and JavaScript&lt;/li&gt;
&lt;li&gt;The Pattern Lab build documentation as a ZIP file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Be aware that in all other cases where we use Pattern Lab, we build the components with Mustache and only deliver the documentation and processed assets. That’s because we usually assume that the developer applies markup and CSS classes as given in the documentation. Hence, this project is an exception.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VYH-u1M1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AiN57031_SPNlX6bqTGpjeg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VYH-u1M1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AiN57031_SPNlX6bqTGpjeg.png" alt="Screenshot of one of our rendered pattern libraries"&gt;&lt;/a&gt;Pattern Lab: A living documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Maintenance: Pattern library first&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The biggest mistake that happens within design systems and pattern libraries probably is that they aren’t maintained&lt;/strong&gt;. This also happened to some of our own pattern libraries. However, this is quite common in the wild.&lt;/p&gt;

&lt;p&gt;In fact, &lt;strong&gt;the pattern library brings another bridge into the game&lt;/strong&gt;. Before, you had to bridge the gap between design and code. Once you use a pattern library you have to connect the design, the pattern library and the final code base that applies the design via the pattern library. This also applies to the most well-known design systems like Material Design. If Google changes the rules and you want to follow them strictly, you have to apply the changes from the design system manually.&lt;/p&gt;

&lt;p&gt;For instance, &lt;a href="https://airbnb.com"&gt;Airbnb&lt;/a&gt; ensured the health of their code by making the developed design system the single source of truth. The starting point for any change in the design is the code base. They developed tools that allow you to &lt;a href="https://airbnb.design/painting-with-code/"&gt;import the code into the design software&lt;/a&gt; and make the maintenance of design files redundant.&lt;/p&gt;

&lt;p&gt;Unfortunately, &lt;strong&gt;we’re not at that point yet&lt;/strong&gt; at Nothing. The best we can do is to make sure that there are no UI changes applied to the final software which aren’t included in the pattern library. This is difficult, especially when everything has to go fast and a bug has to be resolved. But it’s a requirement for a long lasting consistent design.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AKwjbFB1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Ag2khilHUGeLX_rDB4A2JKQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AKwjbFB1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Ag2khilHUGeLX_rDB4A2JKQ.png" alt="Screenshot of Visual Studio Code showing the big folder and file structure of a pattern library"&gt;&lt;/a&gt;A pattern library can grow fast and get big: We prefix actual documentation output with &lt;strong&gt;example-*&lt;/strong&gt; to enable more flexibility on how and what we output in the documentation&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Is it worth investing into a roundtrip for building a pattern library? &lt;strong&gt;If you strive to keep your design consistent and maintainable for a longer time, definitively&lt;/strong&gt;. A pattern library gives you the tools to keep an overview of your design. And it keeps everything in a sustainable place, no matter what technical evolution your final application goes through in the future. It separates UI and logic further from each other. This produces the positive side effect that you hand developers who are more capable of doing styling an isolated environment to play — without having to dig into frameworks and other technologies.&lt;/p&gt;

&lt;p&gt;If you want to see our work in action, you can check out &lt;a href="https://github.com/NothingInteractive/pattern-library-boilerplate"&gt;our current boilerplate that we use to kickstart our projects on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Further reading&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;And if you’re interested in knowing even more about design systems and pattern libraries, follow these links:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.smashingmagazine.com/category/design-systems/"&gt;Design Systems category on Smashing Magazine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.smashingmagazine.com/design-systems-book/"&gt;Smashing Book “Design Systems”&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;





</description>
      <category>design</category>
      <category>html</category>
      <category>css</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
