JavaScript add-ons - Design guide

Each JavaScript style includes a Correct use section. By adhering to the style's intended purpose(s), any future changes in the stylesheets will have predictable outcomes.

Archiving

Indicate that a page has been archived.

Correct use

Refer to: Archiving content documentation

Demo

No demo provided here.

View all archived options

Auto-complete

Add the auto-complete feature to a text input field.

Correct use

Refer to: Auto complete for text input fields documentation

Demo

Type in W for Winnipeg to see the auto-complete behaviour. This enhancement only works in modern browsers. Older browsers require the user to type out the info in full.

View all auto-complete options

Calendar: Date picker

This feature dynamically generates a calendar interface for selecting a date in a form.

Correct use

Refer to: Date picker documentation

Demo

View all date picker options

Calendar: Events calendar

This feature dynamically generates a calendar interface for navigating a list of events.

Correct use

Refer to: Events calendar documentation

Demo

  1. Single-Day Event

    Event Description

View all events calendar options

Charts and graphs

This feature dynamically generates charts from table data.

Correct use

Refer to: Charts and graphs documentation

Demo

2009 Individual Sales by Category
food auto household
Mary 200 160 40
Tom 3 40 30
Brad 10 180 10
Kate 40 80 90

View charts and graphs options

Expand/collaspe

Allows content to be expanded and collapsed.

Correct use

  • Use to hide secondary or tertiary content, not primary content
  • Do not use as a means to tidy up the look of your page. If the page is deemed too busy, consider other options like separating the content over several pages or chunking the information in a more aesthetically pleasing way.
  • Refer to: Expand/collapse content documentation

Feedback form

This component allows users to submit feedback for a specific Web page or the Web site in general.

Correct use

Refer to: Feedback form documentation

Demo

This is a Government of Canada specific product solution.

View the feedback form

Footnotes

This component provides a consistent, accessible way of handling footnotes across websites.

Correct use

Refer to: Footnotes documentation

Demo

Paragraph of information goes here.Footnote 1.

Footnotes

Footnote 1

Footnote go here.

Return to footnote 1 referrer

View all footnotes options

Form validation

This component provides generic validation and error message handling for Web forms.

Correct use

Refer to: Form validation documentation

Demo

Too complex to demo here.

View all form validation options

Geomap

Displays a dynamic map over which information from additinal sources can be overlaid.

Correct use

Refer to: Geomap documentation

Demo

Too complex to demo here.

View all geomap options

Creates a gallery out of pictures or content.

Correct use

Refer to: Light box documentation

Demo

Inline content

Inline content goes here

View all lightbox display options

Mathematical/scientific formula display

The MathML polyfill emulates MathML support in browsers that lack MathML support.

Correct use

Refer to: Mathematical/scientific formula display documentation

Demo

The quadratic equation a x 2 + b x + c = 0

View all mathematical/scientific formula display options

Meter

The HTML5 meter element displays a scalar measurement in a known range.

Correct use

  • The meter element represents a scalar measurement within a known range, or a fractional value; for example disk usage, the relevance of a query result, or the fraction of a voting population to have selected a particular candidate.
  • This is also known as a gauge.
  • The meter element should not be used to indicate progress (as in a progress bar). For that role, HTML provides a separate progress element.
  • The meter element also does not represent a scalar value of arbitrary range — for example, it would be wrong to use this to report a weight, or height, unless there is a known maximum value.
  • Refer to: Meter documentation

Demo

75% (normal)

View all meter options

Multimedia

This feature provides a multimedia player for embedding accessible video and audio into web pages.

Correct use

Refer to: Multimedia player documentation

Persistent storage

The HTML5 localStorage object is used to store data persistently (no expiration date). This component adds support for this object in browsers that do not already have native support.

Correct use

Refer to: Persistent storage documentation

Demo

No demo provided here.

View all local storage options

Progress bar

The HTML5 progress element displays the progress of a task.

Correct use

Refer to: Progress bar documentation

Session timeout

This component helps Web asset owners to provide session timeout and inactivity timeout functionality.

Correct use

Refer to: Session timeout documentation

Demo

Too complex to demo here.

View all session timeout options

Share widget

This component facilitates sharing Web content on social media platforms.

Correct use

Refer to: Share widget documentation

Slide out tab

This component provides a tab at the edge of the content area that can slide out to show content.

Correct use

Refer to: Slide out tab documentation

Demo

Too complex to demo here.

View all slide out tab options

Slider control

The <input type="range" /> allows to display a slider control bar.

Correct use

Refer to: Slider control documentation

Demo

Range: 0 to 100 in steps of 1

View all slider options

Source code (Prettify)

Syntax highlighting of source code snippets in an html page using google-code-prettify.

Correct use

Refer to: Prettify source code documentation

Demo

<label for="data1">Form input default appearance:</label>
<input name="data1" type="text" id="data1" />
	

View all source code options

Tabs / News slider

This component displays multiple pieces of content into a tabbed interface.

Correct use

Jakob Nielsen, a top usability expert, wrote the article Tabs, Used Right (external link), which outlines the correct use of tabs. In this document, he states that tabs should:

  • Not use all-capital letters for the labels;
  • Use only only one row of tabs that are on top of the panel;
  • Alternate only between views within the same type of context, and not navigate to different areas;
    • Tabs should logically chunk information so users can easily predict what they’ll find. They should not have to simultaneously refer to and compare content.
  • Have a highlighted Currently selected tab — with unselected tabs that are clearly visible and readable;
    • The Current tab should connect to the content area.
  • Use plain language and have short titles;
  • Use a parallel naming structure.
    Correct use = parallel labels:
    Incorrect use = unrelated labels:
  • Have an obvious scope that the tabs control;
  • Have a quick click response time (ideally <0.1 s).
  • Refer to: Tabbed interface documentation

Demo

Tab 1 content

Tab 2 content

Tab 3

Tab 3 content. Tab 3 content. Tab 3 content. Tab 3 content.

Tab 4

Tab 4 content. Tab 4 content. Tab 4 content. Tab 4 content.

View all tab and news slider options

Table enhancement

The table enhancement plugin adds advanced functionality such as sorting, filtering, pagination to tables.

Correct use

Refer to: Table enhancement documentation

Demo

Rendering engine Browser
Trident Internet Explorer 4.0
Trident Internet Explorer 5.0
Trident Internet Explorer 5.5
Trident Internet Explorer 6
Trident Internet Explorer 7

View all table enhancement options

Text highlighting

This component automatically highlights certain words on a Web page. The words to highlight can be set through the query string.

Correct use

Refer to: Text highlighting documentation

Demo

Too complex to demo here.

View all text highlighting options

Web feeds

Provides a widget for aggregating and displaying the entries from one or more Web feeds on a Web page.

Correct use

Refer to: Web feeds documentation

Zebra striping

Adds zebra stripes to ordered list, unordered list, definition list, table rows, table columns and provide visual support for the complex data table relationship.

Correct use

Refer to: Zebra striping documentation

Demo

Caption
Header Header
Data Data
Data Data
Data Data
Data Data
Data Data

View all zebra striping options