Buttons

Variations/configurability

Variant

SCSS (recommended)

Extend one of the variant placeholders: %variant-primary, %variant-secondary or %variant-tertiary

HTML attribute

You could set the different button variants via the data-variant attribute.

Size

SCSS (recommended)

Extend one of the size SCSS placeholders in case that you don't want the default (regular): %size-Small or %size-Large

HTML attribute

You could set the different button sizes via the data-size attribute, the default is "regular" and in that case is optional.

Width

Regularly, our buttons shouldn't increase to it's horizontally available space, but only the one determined by it's included textual content.

SCSS (recommended)

Extend the width SCSS placeholders in case that you don't want the default (auto): %width-Full

HTML attribute

You could set the button width to increase to it's full available space via the data-width="full" attribute, the default is auto and in that case is optional.

Usability

Buttons should be used in situations where users might need to:

  • submit a form
  • begin a new task
  • trigger a new UI element to appear on the page
  • specify a new or next step in a process

Button vs. Link

The HTML elements for buttons and links describe a very specific type of action that is going to be taken when they are used. It is important you know when to use which, as the distinction matters:

  • Use a link when you’re navigating to another place, such as: a "view all" page, "Jane Chen" profile, a page "skip link" etc.
  • Use buttons when you are performing an action, such as: "submit," "merge," "create new," "upload," etc.
  • An action is almost always on the same page

Source: https://www.lightningdesignsystem.com/components/buttons/#About-Buttons

Further argumentations:

"Hand" cursor / pointer

We don't use the "hand" cursor / pointer for our buttons, as this is reserved for links even only; for more information have a look at articles like https://medium.com/simple-human/buttons-shouldnt-have-a-hand-cursor-b11e99ca374b and https://hiddedevries.nl/en/blog/2016-08-06-some-pointers-on-default-cursors or people who thought this through like https://ux.stackexchange.com/questions/105024/why-dont-button-html-elements-have-a-css-cursor-pointer-by-default#105027 or https://github.com/necolas/normalize.css/issues/371#issuecomment-60072171 and the UI guidelines from Apple, Microsoft, Google, etc.

Microsoft’s design guides talk about weak affordance:

Text and graphics links use a hand […] pointer […] because of their weak affordance. While links may have other visual clues to indicate that they are links (such as underlines and special placement), displaying the hand pointer on hover is the definitive indication of a link. To avoid confusion, it is imperative not to use the hand pointer for other purposes. For example, command buttons already have a strong affordance, so they don’t need a hand pointer. The hand pointer must mean “this target is a link” and nothing else.

Apple’s Human Interface Guidelines states that the hand cursor should be used when “the content is a URL link”.

W3C User Interface guidelines says the same thing again with “The cursor is a pointer that indicates a link”.

Disabled button state

The disabled state of the button is defined by a change in opacity for good reasons:

A transparent button blends into the background more, while a gray one remains in the foreground (unless the background is gray). Foreground elements are more noticeable to users. They tend to view them as interactive, which means they’re more likely to interact with a grayed out disabled button.

For much more information visit https://uxmovement.com/buttons/why-you-shouldnt-gray-out-disabled-buttons/.

In general disabling buttons is a controversial topic in UX Design, and should get only used well-considered; compare to these articles on how to use disabled buttons only selectively: https://stories.justinewin.com/disabled-buttons-dont-have-to-suck-10da0bb6d37e, https://axesslab.com/disabled-buttons-suck/ and https://www.smashingmagazine.com/2021/08/frustrating-design-patterns-disabled-buttons/

Ambiguous labels

Please keep in mind to use unambiguous labels: https://ebay.gitbook.io/mindpatterns/antipatterns/ambiguous-label

Button

Button Brand Primary

Button Primary

Button Secondary Solid

Button Tertiary Plain

Button Sizes

Small

Regular (default, data-size attribute is optional)

Large

Button Width

Checkbox

Checkbox Checked

Checkbox Disabled

Chips

Variations/configurability

Variant

HTML attribute

You could set the different button variants via the data-variant attribute. These could be either one of the four feedback values, or the "point of interest" stylings.

Filter chips

POIs

Selection chips

POIs

Chips with icon

Chips – disabled

POIs

Headline

Pulse

You could add the DB Pulse to the headline element by adding the data-pulse attribute – we're taking care of sizing it accordingly to the DB logo if this one is also present on the same page, as defined by the rules on the Marketingportal regarding the logo and the pulse.

Headline

Lorem ipsum dolores sint

Headline Pulse

Lorem ipsum dolores sint

Image

Responsive images: width, height and intrinsicsize

There has been some development the latest on the new proposed intrinsicsize attribute for images, that ended with the existing and well known attributes width and height will get used to compute that intrinsicsize directly via UA-stylesheets - so the responsive images and aspect-ratio comes without any costs and leads to that it even makes more sense than ever to fill out those attributes with the basic size of your image in the first place.

For more information have a look at those articles and the standard/proposal:

Image formats

JPEG (AVIF and WebP as progressive enhancement) for photographs etc

Photographs typically fare well with lossy compression (depending on the encoder's configuration). This makes JPEG and WebP good choices for photographs, with JPEG being more compatible but WebP perhaps offering better compression. To maximize quality and minimize download time, consider providing both using a fallback with WebP as the first choice and JPEG as the second. Otherwise, JPEG is the safe choice for compatibility.

Source: https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types#Photographs

Next to WebP you could experiment a little bit with the new image format AVIF that promises even lower file sizes than WebP and increases in browser support.

Additionally have a look at Googles product "Guetzli", that provides great JPEG compression rates as well: https://github.com/google/guetzli/

And another tool even also resulted in fine compression rates - the main difference in between the both of them is that JPEGMini isn't available for free anymore: https://www.jpegmini.com

Attention: PNG is even also often used for pictures, even though that the special capabilities of this format like partial transparency aren't being used. This leads to much huger filesizes in most cases, as the JPEG format is capable of much better compression rates than PNG in general, so you would have to check on this aspect individually and carefully.

Partialy transparent images

Regarding images that need to have some kind of full or partial transparency, you could use either GIF (full) or PNG (most likely PNG-24 for partial) transparency.

Or use SVG masks, as this beautiful concept shows: https://github.blog/2021-01-29-making-githubs-new-homepage-fast-and-performant/#serving-the-perfect-image

Diagrams, drawings, and charts

For any image that can be represented using vector graphics, SVG is the best choice. Otherwise, you should use a lossless format like PNG. If you do choose a lossy format, such as JPEG or lossy WebP, carefully weigh the compression level to avoid causing text or other shapes to become fuzzy or unclear.

Source: https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types#Diagrams_drawings_and_charts

Further image compressions

On top of the possibilities mentioned above regarding image optimizations (Google Guetzli & JPEGMini) you could as well have a look at both ImageAlpha (for PNG) and ImageOptim (for all), both available for Mac and the first both both other GUI and command-line variants and the latter as well as a webservice. Another great online tool that works entirely in the browser and doesn't even need to process your data on their servers (due to WebAssembly and some other cool stuff) is https://squoosh.app. Nowadays they additionally provide a CLI version of their software and new cool image formats, check out their version 2: https://web.dev/squoosh-v2/

Some further information on this topic are provided on this page: https://dev.to/prototyp/optimizing-images-for-the-web-an-in-depth-guide-4j7d

Accessibility

Always provide a link text

All links should have text that uniquely identifies the link target.

Source: https://www.deque.com/blog/accessibility-strategies-for-your-content-team/#:~:text=Link Text

Alt text should communicate the main point

The key is to describe what you want your audience to get out of the image rather than a simple description of what the image is.

Source: https://www.deque.com/blog/accessibility-strategies-for-your-content-team/#:~:text=Images

Using captions

For using captions it's recommended to use the <figure> and <figcaption> HTML tags - but please be aware that you additionally need to enrich those via aria-labelledby or aria-describedby attributes to ensure that assistive technologies are recognizing the linkage of those tags on Windows. It's mainly important to decide whether the figcaption HTML tags content is meant as a description or a label to choose one of those aria-* attributes correctly.

When using the down arrow, NVDA announced all the <img> elements in turn except for the ones with empty or missing alt attributes. These were just completely ignored by the screen reader. Using aria-labelledby overrode any alternate text, and using aria-describedby added the ‘description’ into the alternate text. It’s interesting to note that using aria-labelledby also brought images with missing or empty alternate text to the attention of NVDA.

Source: https://www.hassellinclusion.com/blog/figure-figcaption-extended-alternate-text-screen-readers/

Image

DB Regio train at Munich mainstation

Image - AVIF

DB Regio train at Munich mainstation

Image - Lazy loading

DB Regio train at Munich mainstation
DB Regio train at Munich mainstation
DB Regio train at Munich mainstation

Image - WebP

DB Regio train at Munich mainstation

Image - with caption

DB Regio train at Munich mainstation
DB Regio train at Munich mainstation

Input

label and input elements code structure

We're using the construct of label and input elements shown below (both their order and not nesting them, as a few other frameworks do) for two good reasons:

  • "Generally, explicit labels are better supported by assistive technology." - compare to the W3C spec, seems to be a WCAG criteria that for, too.
  • We could easily control the styling depending on the input elements (pseudo-)states w/o the need for JavaScript

Auto suggestions

You could easily integrate the possibility to provide auto suggestions to your input fields via the list-attribute on the input-HTML-elements as well as adding the suggestions via the datalist-HTML-element. Please follow up within the Input - Auto Suggestions section.

Autofill

For heavily supporting the user on autofilling form fields (not only, but especially on mobile browsing) with information even already available on their devices, you could use the autocomplete attribute, as described e.g. here https://cloudfour.com/thinks/autofill-what-web-devs-should-know-but-dont/

The attribute doesn't even only take boolean values, but even also a list of specific field types, as described in the specification: https://html.spec.whatwg.org/multipage/forms.html#inappropriate-for-the-control

Form validation

Please have a look especially at the section for form validation within the overall components/forms page.

Additionally to the browser built-in pseudo-selector :user-invalid we're providing styling for the aria-invalid="true" attribute as well.

Accessibility support

For our special construct (the order of the label and input HTML tags) we need to additionaly set some further attributes on those HTML tags to better support assistive tools (screenreaders like JAWS and VoiceOver); set the aria-labelledby-attribute on the input and related id on the label as well as aria-hidden="true", e.g. like this:

<input
  type="text"
  class="elm-input"
  placeholder="Projekt Name"
  name="input01"
  id="input01"
  aria-labelledby="input01-label"
/>
<label class="elm-label" for="input01" aria-hidden="true" id="input01-label"
  >Textlabel</label
>

We've conducted some tests with those assistive tools that lead to the conclusion that either the labels content hasn't been read out to the screenreader user on those form fields directly, but the labels content has been read again after the form field e.g. on VoiceOver. So those declarations are necessary for this kind of HTML construct, that is especially relevant for form validation and floating label functionality via CSS only.

Input variations

semitransparent:
white:
solid:
outline:

Input

Input with description

Optionale Beschreibung
Zeile zwei

Optionale Beschreibung
Zeile zwei

Input - valid state

Optionale Beschreibung
Zeile zwei

Optionale Beschreibung
Zeile zwei

Input - disabled state

Input - Hidden label

Loading Indicator

Progress spinners (loading indicators) show the user that a longer-lasting action is being carried out.
Progress/Loading Indicators are used when the application executes a server request or processes data in the frontend. The component is used as soon as the execution and the resulting delay are noticeable to the user. This keeps the user aware that his or her action is being executed.

Accessibility

SVGs are often conveyed inconsistently to assistive technologies. The component’s accessibility is also highly contextual. For optimal user experience, use the aria-description prop to let assistive technology users know the purpose of the loading spinner.

aria-live and dynamic creation of html content

Using JavaScript (e.g. in context of frameworks like Angular, VueJS or React), it is possible to dynamically change parts of a page without requiring the entire page to reload — for instance, to update a list of search results on the fly, or to display a discreet alert or notification which does not require user interaction. While these changes are usually visually apparent to users who can see the page, they may not be obvious to users of assistive technologies. ARIA live regions fill this gap and provide a way to programmatically expose dynamic content changes in a way that can be announced by assistive technologies.

aria-live triggers screen readers when an element with aria-live (or text within an element with aria-live) is added or removed from the DOM. In contrast, when you unhide a hidden element, neither elements nor text are added or removed from the DOM, so the element's aria-live property doesn’t come into play.

Note that the live region needs to be present in the markup before the notification is generated or updated. If you dynamically generate both at the same time and inject them into the page, they will generally not be announced by assistive technologies.

You also need to adapt the role and aria-live level depending on the content. Further information can be found here https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions

Recommendations

Do

If the application is waiting for a process, it makes sense to display an indicator in a central location.

Don‘t

An indicator should not be used to visualize the application waiting for user input.

Loading Indicator

Example description for loading spinner
Example description for s loading spinner
Example description for xs loading spinner
Example description for loading spinner size M
Example description for loading spinner size L
Example description for loading spinner size XL

Logo On Backgrounds

Logo Sizes

Lorem ipsum dolores sint

Linear loader

Linear spinner

Radio

Form validation

Please have a look especially at the section for form validation within the overall components/forms page.

Additionally to the browser built-in pseudo-selector :user-invalid we're providing styling for the aria-invalid="true" attribute as well.

Radios




Radios Checked




Radios Disabled










Radio - Hidden label




Radios Required




Select

This element doesn't fulfill the styleguides definitions especially on the option elements styling, as this isn't possible x-browser without JavaScript. If you would like to even also match those visual requirements, you would need to choose a progressive JavaScript solution on your own.

Form validation

Please have a look especially at the section for form validation within the overall components/forms page.

Additionally to the browser built-in pseudo-selector :user-invalid we're providing styling for the aria-invalid="true" attribute as well.

Select

Select Variations

semitransparent:
white:
solid:
outline:
semitransparent:
white:
solid:
outline:
semitransparent:
white:
solid:
outline:

Select - Hidden label

Tags

Variations/configurability

Variant

HTML attribute

You could set the different button variants via the data-variant attribute. These could be either one of the four feedback values, or the "point of interest" stylings.

Size

SCSS (recommended)

Extend the size placeholder in case that you don't want the default (regular): %size-Small

HTML attribute

You could set the different button sizes via the data-size attribute, the default is "regular" and in that case is optional.

Tags

Default Light Informative Success Warning Error Gl. 10

POIs

Essen & Trinken Einkaufen Gesundheit Kunst & Kultur Wissenswertes Freizeit Zivile & reli. Einrichtungen Dienstleistungen DB Services & Einrichtung Wegeleitung

Tags Small

Default Light Informative Success Warning Error Gl. 10

POIs

Essen & Trinken Einkaufen Gesundheit Kunst & Kultur Wissenswertes Freizeit Zivile & reli. Einrichtungen Dienstleistungen DB Services & Einrichtung Wegeleitung

Tags With Icon

Default Light Informative Success Warning Error Gl. 10

Textarea

Form validation

Please have a look especially at the section for form validation within the overall components/forms page.

Additionally to the browser built-in pseudo-selector :user-invalid we're providing styling for the aria-invalid="true" attribute as well.

Textarea variations

semitransparent:
white:
solid:
outline:

Textarea

Textarea Disabled

Optionale Beschreibung
Zeile zwei

Textarea - valid state

Toggle

Toggle Disabled

Toggle On

Toggle On Disabled