Philosophy & Principles

Before is a classless, semantic style reset that styles HTML5 elements directly, providing accessible defaults without relying on utility-first CSS libraries or overly complex frameworks. It is themeable (via CSS custom properties) and designed for progressive enhancement, allowing further customization through classes, components, or frameworks when desired. By targeting semantic HTML, it provides a rock-solid, long-term foundation. All components are implemented according to the ARIA Authoring Practices Guide (APG), ensuring they are accessible, predictable, and keyboard-friendly, so your semantic HTML remains usable for everyone.

Getting Started

To get started, simply copy/paste the Before.css file into your project and link to it in the head of your HTML document.

Elements

The following visual HTML5 elements are styled by Before:

<a> - Anchor element that creates a hyperlink to other pages, files, or locations.

Default Link

A standard hyperlink with underline styling that inherits the current text color.

Click here to learn more
<a href="#">Click here to learn more</a>

Visited Link

Links that have been visited maintain the current color with slightly reduced opacity.

Previously visited link
<a href="#visited-example">Previously visited link</a>

External Link

Links with target="_blank" automatically display an external link indicator (↗).

Visit Example.com
<a href="https://example.com" target="_blank" rel="noopener noreferrer">Visit Example.com</a>

Download Link

Links with the download attribute display a download indicator (↓) before the text.

Download PDF
<a href="/files/document.pdf" download>Download PDF</a>

Email Link

Links with mailto: protocol display an email icon (✉) before the text.

hello@example.com
<a href="mailto:hello@example.com">hello@example.com</a>

Phone Link

Links with tel: protocol display a phone icon (📞) before the text.

+1 (234) 567-890
<a href="tel:+1234567890">+1 (234) 567-890</a>

Disabled Link

Use aria-disabled="true" to visually disable a link while maintaining accessibility.

Unavailable link
<a href="#" aria-disabled="true">Unavailable link</a>

Current Page Link

Use aria-current="page" to indicate the current page in navigation. The link appears bold without underline.

<nav>
  <a href="/">Home</a>
  <a href="/about" aria-current="page">About</a>
  <a href="/contact">Contact</a>
</nav>

Skip Link

A hidden link that becomes visible on focus, allowing keyboard users to skip to main content.

Skip to main content
Main content here...
<a href="#main-content">Skip to main content</a>
<main id="main-content">Main content here...</main>
<abbr> - Represents an abbreviation or acronym with an optional title for the full description.

Abbreviation

Dotted underline indicates hover for full text.

The WWW changed everything.

<p>The <abbr title="World Wide Web">WWW</abbr> changed everything.</p>
<address> - Provides contact information for the nearest article or body ancestor.

Address

Italic contact information block.

Contact: info@example.com
123 Main St, City
<address>
  Contact: <a href="mailto:info@example.com">info@example.com</a><br>
  123 Main St, City
</address>
<article> - Represents a self-contained composition intended for independent distribution or reuse.

Article

Self-contained content block with implicit padding.

Article Title

Article content goes here...

<article>
  <h2>Article Title</h2>
  <p>Article content goes here...</p>
</article>
<aside> - Represents content tangentially related to the main content, often used for sidebars.

Aside

Sidebar or supplementary content with subtle styling.

<aside>
  <h3>Related Links</h3>
  <ul>
    <li><a href="#">Link one</a></li>
    <li><a href="#">Link two</a></li>
  </ul>
</aside>
<audio> - Embeds sound content with controls for playback.

Audio Player

Full-width audio player with native controls.

<audio controls>
  <source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4
" type="audio/mpeg">
  Your browser does not support audio.
</audio>
<b> - Represents text stylistically offset from normal text without conveying extra importance.

Bold

Bold text for stylistic offset.

The quick brown fox jumps.

<p>The <b>quick</b> brown fox jumps.</p>
<blockquote> - Indicates an extended quotation from another source.

Block Quote

Indented with a left border to distinguish quoted content.

The only way to do great work is to love what you do.

<blockquote>
  <p>The only way to do great work is to love what you do.</p>
</blockquote>
<body> - Represents the content of an HTML document.

Default Body

Clean, readable defaults with system fonts, comfortable line height, and responsive max-width for optimal reading.

The body element provides the foundation for all content. It uses system fonts for fast loading and familiar appearance.

<p>The body element provides the foundation for all content. It uses system fonts for fast loading and familiar appearance.</p>
<br> - Produces a line break in text.

Line Break

Forces a line break within text.

Line one
Line two

<p>Line one<br>Line two</p>
<canvas> - Container for graphics drawn via scripting (usually JavaScript).

Canvas

Drawing surface with responsive sizing.

Your browser does not support canvas.
<canvas width="300" height="150">
  Your browser does not support canvas.
</canvas>
<caption> - Specifies the title of a table.

Table Caption

Descriptive title displayed above the table.

Monthly Sales Data
MonthSales
Jan$1,000
<table>
  <caption>Monthly Sales Data</caption>
  <tr><th>Month</th><th>Sales</th></tr>
  <tr><td>Jan</td><td>$1,000</td></tr>
</table>
<cite> - Represents the title of a creative work being referenced.

Citation

Italic text for referencing creative works.

My favorite book is The Great Gatsby.

<p>My favorite book is <cite>The Great Gatsby</cite>.</p>
<code> - Displays a fragment of computer code.

Inline Code

Inline code with subtle background for visibility.

Use the console.log() function to debug.

<p>Use the <code>console.log()</code> function to debug.</p>

Code Block

Wrap code in pre for multi-line code blocks.

function greet(name) {
  return "Hello, " + name;
}
<pre><code>function greet(name) {
  return "Hello, " + name;
}</code></pre>
<data> - Links content with a machine-readable translation.

Data

Machine-readable value with human display.

Price: $49.99

<p>Price: <data value="49.99">$49.99</data></p>
<dd> - Provides the description or value for a term in a description list.

Definition Description

Indented description for a term.

CSS
Cascading Style Sheets
<dl>
  <dt>CSS</dt>
  <dd>Cascading Style Sheets</dd>
</dl>
<del> - Represents text that has been deleted from a document.

Deleted Text

Strikethrough styling to indicate removed content.

Price: $50 $30

<p>Price: <del>$50</del> $30</p>
<details> - Creates a disclosure widget from which the user can obtain additional information.

Disclosure Widget

Expandable content with toggle control.

Click to expand

Hidden content revealed when expanded.

<details>
  <summary>Click to expand</summary>
  <p>Hidden content revealed when expanded.</p>
</details>
<dialog> - Represents a dialog box or other interactive component.

Dialog

A modal dialog box for user interaction.

This is a dialog box.

<button onclick="document.querySelector('dialog').showModal()">Open Dialog</button>
<dialog>
  <p>This is a dialog box.</p>
  <button onclick="this.closest('dialog').close()">Close</button>
</dialog>
<dfn> - Indicates the defining instance of a term.

Definition

Italic styling for terms being defined.

A pixel is the smallest unit of a digital image.

<p>A <dfn>pixel</dfn> is the smallest unit of a digital image.</p>
<div> - A generic container for flow content with no semantic meaning.

Div Container

Generic block-level container.

Content inside a div.

<div>
  <p>Content inside a div.</p>
</div>
<dl> - Represents a description list of term-description pairs.

Description List

A list of terms and their descriptions, perfect for glossaries or metadata.

Term
The definition or description of the term.
Another Term
Another definition.
<dl>
  <dt>Term</dt>
  <dd>The definition or description of the term.</dd>
  <dt>Another Term</dt>
  <dd>Another definition.</dd>
</dl>
<dt> - Specifies a term in a description list.

Definition Term

Bold term in a definition list.

HTML
HyperText Markup Language
<dl>
  <dt>HTML</dt>
  <dd>HyperText Markup Language</dd>
</dl>
<em> - Marks text with stress emphasis.

Emphasized Text

Italic text for stress emphasis.

I really mean it.

<p>I <em>really</em> mean it.</p>
<embed> - Embeds external content from an external application or plugin.
<fieldset> - Groups related elements within a form.

Form Group

Bordered container for grouping related form fields.

Personal Info
<fieldset>
  <legend>Personal Info</legend>
  <label>Name</label>
  <input type="text">
  <label>Email</label>
  <input type="email">
</fieldset>
<figcaption> - Represents a caption or legend for a figure.

Figure Caption

Smaller, muted text for describing figure content.

Photo by Jane Doe, 2024
<figcaption>Photo by Jane Doe, 2024</figcaption>
<figure> - Represents self-contained content with an optional caption.

Figure with Caption

Image container with descriptive caption below.

Sample
A descriptive caption for the image.
<figure>
  <img src="https://picsum.photos/400/200" alt="Sample">
  <figcaption>A descriptive caption for the image.</figcaption>
</figure>
<form> - Represents a section containing interactive controls for submitting information.

Basic Form

A simple form with inputs and a submit button.

<form>
  <label>Name</label>
  <input type="text" placeholder="Your name">
  <label>Email</label>
  <input type="email" placeholder="you@example.com">
  <button type="submit">Submit</button>
</form>
<h1> - Represents the highest level section heading.

Page Heading

The main heading of the page. Bold and large for clear hierarchy.

Main Page Title

<h1>Main Page Title</h1>
<h2> - Represents a second-level section heading.

Heading 2

Major section heading at 2rem size.

Section Heading

<h2>Section Heading</h2>
<h3> - Represents a third-level section heading.

Heading 3

Subsection heading at 1.5rem size.

Subsection Heading

<h3>Subsection Heading</h3>
<h4> - Represents a fourth-level section heading.

Heading 4

Minor heading at 1.25rem size.

Minor Heading

<h4>Minor Heading</h4>
<h5> - Represents a fifth-level section heading.

Heading 5

Small heading at 1rem size.

Small Heading
<h5>Small Heading</h5>
<h6> - Represents the lowest level section heading.

Heading 6

Smallest heading at 0.875rem size.

Smallest Heading
<h6>Smallest Heading</h6>
<hgroup> - Groups a heading with related content such as subheadings.

Heading Group

Groups heading with subtitle, reduced spacing between.

Main Title

Subtitle or tagline

<hgroup>
  <h1>Main Title</h1>
  <p>Subtitle or tagline</p>
</hgroup>
<hr> - Represents a thematic break between paragraph-level elements.

Horizontal Rule

A subtle line to separate content sections.

Content above the break.


Content below the break.

<p>Content above the break.</p>
<hr>
<p>Content below the break.</p>
<i> - Represents text in an alternate voice or mood, such as technical terms or foreign phrases.

Italic

Italic text for alternate voice or mood.

The word café is from French.

<p>The word <i>café</i> is from French.</p>
<iframe> - Embeds another HTML page within the current page.

Iframe

Embedded frame with no border.

<iframe src="https://example.com" title="Embedded page"></iframe>
<img> - Embeds an image into the document.

Image

Responsive image that scales to its container.

Sample image
<img src="https://picsum.photos/400/200" alt="Sample image">
<input> - Creates interactive form controls for accepting user data.

Text Input

Standard text input with clean borders and focus state.

<input type="text" placeholder="Enter text...">

Checkbox

Checkbox input using system accent color.

<label><input type="checkbox"> Accept terms</label>

Radio

Radio button for single selection from a group.

<label><input type="radio" name="option"> Option A</label>
<label><input type="radio" name="option"> Option B</label>
<ins> - Represents text that has been added to a document.

Inserted Text

Underlined to indicate newly added content.

We now offer free shipping on all orders.

<p>We now offer <ins>free shipping</ins> on all orders.</p>
<kbd> - Represents user keyboard input.

Keyboard Key

Styled like a physical keyboard key with border and shadow.

Press Ctrl + S to save.

<p>Press <kbd>Ctrl</kbd> + <kbd>S</kbd> to save.</p>
<label> - Represents a caption for an item in a user interface.

Form Label

Block-level label with subtle weight.

<label>Username</label>
<input type="text">
<legend> - Represents a caption for a fieldset.

Fieldset Legend

Caption displayed on fieldset border.

Account Info
<fieldset>
  <legend>Account Info</legend>
  <label>Email</label>
  <input type="email">
</fieldset>
<li> - Represents an item in a list.

List Item

Individual list items with comfortable spacing.

  • A single list item with proper vertical rhythm
<ul>
  <li>A single list item with proper vertical rhythm</li>
</ul>
<main> - Represents the dominant content of the body of a document.

Main Content

Primary content area of the document.

Page Title

Main content goes here...

<main>
  <h1>Page Title</h1>
  <p>Main content goes here...</p>
</main>
<mark> - Represents text marked or highlighted for reference or notation.

Highlighted Text

Yellow highlight for marking relevant content.

Search results: The quick brown fox jumps over the lazy dog.

<p>Search results: The <mark>quick brown fox</mark> jumps over the lazy dog.</p>
<object> - Represents an external resource such as an image, plugin, or nested browsing context.
<ol> - Represents an ordered list of items.

Basic Ordered List

A numbered list for sequential content.

  1. First step
  2. Second step
  3. Third step
<ol>
  <li>First step</li>
  <li>Second step</li>
  <li>Third step</li>
</ol>
<output> - Container for the result of a calculation or user action.

Output

Displays calculation results inline.

Total: 42

<p>Total: <output>42</output></p>
<p> - Represents a paragraph of text.

Basic Paragraph

Standard paragraph with comfortable line height and spacing.

This is a paragraph of text. It has comfortable line height for readability and proper spacing between consecutive paragraphs.

This is a second paragraph demonstrating the vertical rhythm between paragraphs.

<p>This is a paragraph of text. It has comfortable line height for readability and proper spacing between consecutive paragraphs.</p>
<p>This is a second paragraph demonstrating the vertical rhythm between paragraphs.</p>
<picture> - Contains source elements and one img element for responsive images.

Picture

Responsive image container for multiple sources.

Responsive image
<picture>
  <source srcset="https://picsum.photos/seed/button/800/400" media="(min-width: 800px)">
  <img src="https://picsum.photos/seed/button/400/200" alt="Responsive image">
</picture>
<pre> - Represents preformatted text preserving whitespace and line breaks.

Preformatted Text

Preserves whitespace and uses monospace font with subtle background.

Line 1
Line 2
  Indented line
<pre>Line 1
Line 2
  Indented line</pre>
<progress> - Displays the completion progress of a task.

Progress Bar

Visual progress indicator using the primary color.

<progress value="70" max="100"></progress>
<q> - Represents a short inline quotation.

Inline Quote

Automatically wrapped with quotation marks.

She said, This is amazing!

<p>She said, <q>This is amazing!</q></p>
<s> - Represents text that is no longer accurate or relevant.

Strikethrough

Text with line through indicating outdated content.

Price: $50 $35

<p>Price: <s>$50</s> $35</p>
<samp> - Represents sample output from a computer program.

Sample Output

Monospace font for computer output.

The error was: File not found

<p>The error was: <samp>File not found</samp></p>
<section> - Represents a standalone section of a document.

Section

Thematic grouping of content.

Section Heading

Section content...

<section>
  <h2>Section Heading</h2>
  <p>Section content...</p>
</section>
<select> - Represents a control providing a menu of options.

Select Dropdown

Dropdown menu for selecting from predefined options.

<select>
  <option>Choose an option</option>
  <option>Option 1</option>
  <option>Option 2</option>
  <option>Option 3</option>
</select>
<small> - Represents side comments or small print.

Small Print

Reduced font size for fine print or disclaimers.

Price: $99 (plus tax)

<p>Price: $99 <small>(plus tax)</small></p>
<span> - A generic inline container for phrasing content.

Span

Generic inline container.

This is inline content in a paragraph.

<p>This is <span>inline content</span> in a paragraph.</p>
<strong> - Indicates text with strong importance or urgency.

Strong Text

Bold text for emphasis and importance.

This is very important information.

<p>This is <strong>very important</strong> information.</p>
<sub> - Represents subscript text.

Subscript

Text positioned below the baseline.

H2O is the chemical formula for water.

<p>H<sub>2</sub>O is the chemical formula for water.</p>
<summary> - Specifies a visible heading for a details element.

Summary

Clickable heading that toggles the details content.

Show more info

Additional information here.

<details>
  <summary>Show more info</summary>
  <p>Additional information here.</p>
</details>
<sup> - Represents superscript text.

Superscript

Text positioned above the baseline.

E = mc2 is Einstein's famous equation.

<p>E = mc<sup>2</sup> is Einstein's famous equation.</p>
<table> - Represents tabular data with rows and columns.

Basic Table

A simple table with headers and data cells.

NameAge
Alice30
Bob25
<table>
  <thead>
    <tr><th>Name</th><th>Age</th></tr>
  </thead>
  <tbody>
    <tr><td>Alice</td><td>30</td></tr>
    <tr><td>Bob</td><td>25</td></tr>
  </tbody>
</table>
<tbody> - Groups the body content rows of a table.

Table Body

Container for table body rows.

Name
Alice
Bob
<table>
  <thead>
    <tr><th>Name</th></tr>
  </thead>
  <tbody>
    <tr><td>Alice</td></tr>
    <tr><td>Bob</td></tr>
  </tbody>
</table>
<td> - Represents a data cell in a table.

Table Data Cell

Standard data cell with padding and border.

ItemPrice
Apple$1.50
Banana$0.75
<table>
  <tr><th>Item</th><th>Price</th></tr>
  <tr><td>Apple</td><td>$1.50</td></tr>
  <tr><td>Banana</td><td>$0.75</td></tr>
</table>
<textarea> - Represents a multi-line plain text editing control.

Text Area

Multi-line input with resizable height.

<textarea placeholder="Enter your message..."></textarea>
<tfoot> - Groups the footer content rows of a table.

Table Footer

Container for table footer rows, often for totals.

ItemCost
Item 1$5
Total$5
<table>
  <thead><tr><th>Item</th><th>Cost</th></tr></thead>
  <tbody><tr><td>Item 1</td><td>$5</td></tr></tbody>
  <tfoot><tr><td>Total</td><td>$5</td></tr></tfoot>
</table>
<th> - Represents a header cell in a table.

Table Header

Bold header cell with bottom border.

NameAgeCity
Alice30NYC
<table>
  <tr><th>Name</th><th>Age</th><th>City</th></tr>
  <tr><td>Alice</td><td>30</td><td>NYC</td></tr>
</table>
<thead> - Groups the header content rows of a table.

Table Head

Container for table header rows.

ProductPrice
Widget$10
<table>
  <thead>
    <tr><th>Product</th><th>Price</th></tr>
  </thead>
  <tbody>
    <tr><td>Widget</td><td>$10</td></tr>
  </tbody>
</table>
<time> - Represents a specific period in time or a machine-readable datetime.

Time

Machine-readable date/time with human display.

Published on

<p>Published on <time datetime="2024-01-15">January 15, 2024</time></p>
<tr> - Represents a row of cells in a table.

Table Row

Horizontal row containing table cells.

Col 1Col 2
A1A2
B1B2
<table>
  <tr><th>Col 1</th><th>Col 2</th></tr>
  <tr><td>A1</td><td>A2</td></tr>
  <tr><td>B1</td><td>B2</td></tr>
</table>
<u> - Represents text with an unarticulated annotation, such as misspelled words.

Underline

Wavy underline for annotated text like spelling errors.

Check the speling of this word.

<p>Check the <u>speling</u> of this word.</p>
<ul> - Represents an unordered list of items.

Basic Unordered List

A bullet list with proper spacing and indentation.

  • First item
  • Second item
  • Third item
<ul>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
</ul>

Nested List

Lists can be nested for hierarchical content.

  • Parent item
    • Child item
    • Another child
  • Another parent
<ul>
  <li>Parent item
    <ul>
      <li>Child item</li>
      <li>Another child</li>
    </ul>
  </li>
  <li>Another parent</li>
</ul>
<var> - Represents the name of a variable in a mathematical or programming context.

Variable

Italic monospace for variable names.

Let x equal the number of items.

<p>Let <var>x</var> equal the number of items.</p>
<video> - Embeds video content with playback controls.

Video Player

Responsive video with native controls.

<video controls>
  <source src="https://storage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
" type="video/mp4">
  Your browser does not support video.
</video>

Components

The following components are built using semantic HTML and styled by Before:

Accordion - A vertically stacked set of interactive headings that each reveal a section of content.

Basic Accordion

A simple accordion using native details/summary elements with exclusive behavior via the name attribute.

What is an accordion?

An accordion is a vertically stacked set of interactive headings that each reveal a section of content.

When should I use an accordion?

Use accordions when you have multiple sections of content that users may want to browse through without leaving the page.

Are accordions accessible?

Yes, when built with native details/summary elements, accordions are keyboard navigable and screen reader friendly.

<div role="region" aria-label="FAQ">
  <details name="accordion-basic">
    <summary>What is an accordion?</summary>
    <p>An accordion is a vertically stacked set of interactive headings that each reveal a section of content.</p>
  </details>
  <details name="accordion-basic">
    <summary>When should I use an accordion?</summary>
    <p>Use accordions when you have multiple sections of content that users may want to browse through without leaving the page.</p>
  </details>
  <details name="accordion-basic">
    <summary>Are accordions accessible?</summary>
    <p>Yes, when built with native details/summary elements, accordions are keyboard navigable and screen reader friendly.</p>
  </details>
</div>

Accordion with Default Open

An accordion where one panel starts expanded using the open attribute.

<nav aria-label="Product categories">
  <details name="accordion-open" open>
    <summary>Electronics</summary>
    <ul>
      <li>Phones</li>
      <li>Laptops</li>
      <li>Tablets</li>
    </ul>
  </details>
  <details name="accordion-open">
    <summary>Clothing</summary>
    <ul>
      <li>Shirts</li>
      <li>Pants</li>
      <li>Shoes</li>
    </ul>
  </details>
  <details name="accordion-open">
    <summary>Home & Garden</summary>
    <ul>
      <li>Furniture</li>
      <li>Decor</li>
      <li>Plants</li>
    </ul>
  </details>
</nav>

Nested Accordion

Accordions can be nested to create hierarchical content structures.

Documentation

Getting Started
Installation

Run npm install to get started with the project.

Configuration

Edit the config file to customize your setup.

API Reference
Components

Learn about available component APIs.

Utilities

Explore utility functions and helpers.

<section aria-labelledby="docs-heading">
  <h3 id="docs-heading">Documentation</h3>
  <details name="accordion-nested">
    <summary>Getting Started</summary>
    <details>
      <summary>Installation</summary>
      <p>Run npm install to get started with the project.</p>
    </details>
    <details>
      <summary>Configuration</summary>
      <p>Edit the config file to customize your setup.</p>
    </details>
  </details>
  <details name="accordion-nested">
    <summary>API Reference</summary>
    <details>
      <summary>Components</summary>
      <p>Learn about available component APIs.</p>
    </details>
    <details>
      <summary>Utilities</summary>
      <p>Explore utility functions and helpers.</p>
    </details>
  </details>
</section>
Alert - A live region that displays important, time-sensitive information to the user.

Basic Alert

A simple alert for displaying messages to users.

Notice: Your session will expire in 5 minutes.
<div role="alert">
  <strong>Notice:</strong> Your session will expire in 5 minutes.
</div>

Alert Tones

Alerts with different semantic tones using data-tone attribute.

Success! Your changes have been saved.
Warning: This action cannot be undone.
Error: Failed to save changes.
Info: New features are available.
<div role="alert" data-tone="success">
  <strong>Success!</strong> Your changes have been saved.
</div>
<div role="alert" data-tone="warning">
  <strong>Warning:</strong> This action cannot be undone.
</div>
<div role="alert" data-tone="error">
  <strong>Error:</strong> Failed to save changes.
</div>
<div role="alert" data-tone="info">
  <strong>Info:</strong> New features are available.
</div>
Button - An interactive element that triggers an action when activated by the user.

Button Variants

Different button styles using data-variant attribute.

<div style="display: flex; gap: 1em; flex-wrap: wrap;">
  <button>Primary</button>
  <button data-variant="secondary">Secondary</button>
  <button data-variant="ghost">Ghost</button>
  <button data-variant="danger">Danger</button>
  <button disabled>Disabled</button>
</div>

Button as Link

An anchor element styled as a button using role='button'.

Link Button
<a href="#" role="button">Link Button</a>
Checkbox - A form control that allows users to select one or more options from a set.

Checkbox States

Checkboxes in various states.

<div style="display: flex; flex-direction: column; gap: 0.5em;">
  <label><input type="checkbox"> Unchecked</label>
  <label><input type="checkbox" checked> Checked</label>
  <label><input type="checkbox" disabled> Disabled</label>
  <label><input type="checkbox" checked disabled> Checked & Disabled</label>
</div>
Combobox - A composite widget combining a text input with a popup listbox for selecting values.

Basic Combobox

A text input with an associated listbox.

  • Apple
  • Banana
  • Cherry
  • Date
<div role="combobox" aria-expanded="true" aria-haspopup="listbox">
  <input type="text" placeholder="Select a fruit..." aria-autocomplete="list">
  <ul role="listbox">
    <li role="option">Apple</li>
    <li role="option" aria-selected="true">Banana</li>
    <li role="option">Cherry</li>
    <li role="option">Date</li>
  </ul>
</div>
Dialog - A modal or non-modal window that appears above the page content requiring user interaction.

Basic Dialog

A modal dialog with header and footer.

Confirm Action

Are you sure you want to proceed with this action?

<dialog>
  <header>
    <h3>Confirm Action</h3>
  </header>
  <p>Are you sure you want to proceed with this action?</p>
  <footer>
    <button data-variant="secondary">Cancel</button>
    <button>Confirm</button>
  </footer>
</dialog>
Disclosure - A button that controls the visibility of a section of content.

Basic Disclosure

A collapsible section using the native details/summary elements.

Click to reveal more information

This content is hidden by default and revealed when the summary is clicked.

You can include any content here.

<details>
  <summary>Click to reveal more information</summary>
  <p>This content is hidden by default and revealed when the summary is clicked.</p>
  <p>You can include any content here.</p>
</details>

Disclosure (Open by Default)

A disclosure that starts in the open state.

Already expanded

This content is visible by default because the open attribute is present.

<details open>
  <summary>Already expanded</summary>
  <p>This content is visible by default because the open attribute is present.</p>
</details>
Feed - A scrollable list of articles where new content may be added as the user scrolls.

Basic Feed

A feed of articles with proper ARIA attributes.

First Article

Content of the first article...

Second Article

Content of the second article...

Third Article

Content of the third article...

<section role="feed" aria-label="News feed">
  <article aria-posinset="1" aria-setsize="3" tabindex="0">
    <h4>First Article</h4>
    <p>Content of the first article...</p>
  </article>
  <article aria-posinset="2" aria-setsize="3" tabindex="0">
    <h4>Second Article</h4>
    <p>Content of the second article...</p>
  </article>
  <article aria-posinset="3" aria-setsize="3" tabindex="0">
    <h4>Third Article</h4>
    <p>Content of the third article...</p>
  </article>
</section>
Grid - An interactive two-dimensional data structure with rows and columns of cells.

Basic Grid

An interactive grid with keyboard navigation support.

Name
Email
Role
Alice
alice@example.com
Admin
Bob
bob@example.com
User
<div role="grid" aria-label="Sample data" style="grid-template-columns: repeat(3, 1fr);">
  <div role="row">
    <div role="columnheader">Name</div>
    <div role="columnheader">Email</div>
    <div role="columnheader">Role</div>
  </div>
  <div role="row">
    <div role="gridcell" tabindex="0">Alice</div>
    <div role="gridcell">alice@example.com</div>
    <div role="gridcell">Admin</div>
  </div>
  <div role="row">
    <div role="gridcell" tabindex="-1">Bob</div>
    <div role="gridcell">bob@example.com</div>
    <div role="gridcell">User</div>
  </div>
</div>
Landmarks - Semantic regions that help assistive technology users navigate and understand page structure.

Page Landmarks

Semantic landmark elements for page structure.

<header> - Page header
<main> - Main content
<footer> - Page footer
<div style="border: 1px dashed var(--surface_muted); padding: 1em;">
  <header style="padding: 0.5em; background: var(--surface_raised);">
    <header> - Page header
  </header>
  <nav style="padding: 0.5em; background: var(--surface_overlay); margin-block: 0.5em;">
    <nav> - Navigation
  </nav>
  <main style="padding: 0.5em; background: var(--surface_raised);">
    <main> - Main content
    <aside style="margin: 0.5em 0;">
      <aside> - Sidebar
    </aside>
  </main>
  <footer style="padding: 0.5em; background: var(--surface_overlay);">
    <footer> - Page footer
  </footer>
</div>
Listbox - A widget that allows users to select one or more items from a list of choices.

Single Select Listbox

A listbox for selecting a single option.

  • Red
  • Green
  • Blue
  • Yellow (unavailable)
<ul role="listbox" aria-label="Select a color">
  <li role="option" aria-selected="false" tabindex="0">Red</li>
  <li role="option" aria-selected="true" tabindex="-1">Green</li>
  <li role="option" aria-selected="false" tabindex="-1">Blue</li>
  <li role="option" aria-disabled="true" tabindex="-1">Yellow (unavailable)</li>
</ul>
Meter - A graphical display of a numeric value within a known range.

Meter States

Meters showing different value ranges.

<div style="display: flex; flex-direction: column; gap: 1em;">
  <label>Storage (optimal): <meter value="0.3" min="0" max="1" low="0.25" high="0.75" optimum="0.1"></meter></label>
  <label>Memory (suboptimal): <meter value="0.7" min="0" max="1" low="0.25" high="0.75" optimum="0.1"></meter></label>
  <label>CPU (critical): <meter value="0.95" min="0" max="1" low="0.25" high="0.75" optimum="0.1"></meter></label>
</div>
Radio - A group of mutually exclusive options where only one can be selected at a time.

Radio Group

A group of radio buttons for single selection.

Choose a color:
<fieldset role="radiogroup" aria-label="Favorite color">
  <legend>Choose a color:</legend>
  <label><input type="radio" name="color" value="red"> Red</label>
  <label><input type="radio" name="color" value="green" checked> Green</label>
  <label><input type="radio" name="color" value="blue"> Blue</label>
  <label><input type="radio" name="color" value="yellow" disabled> Yellow (unavailable)</label>
</fieldset>
Slider - An input control that allows users to select a value from a range by dragging a thumb.

Range Slider

A slider for selecting a value within a range.

<div style="display: flex; flex-direction: column; gap: 1em;">
  <label>Volume: <input type="range" min="0" max="100" value="50"></label>
  <label>Brightness: <input type="range" min="0" max="100" value="75"></label>
  <label>Disabled: <input type="range" min="0" max="100" value="25" disabled></label>
</div>
Spinbutton - A numeric input field with increment and decrement buttons for adjusting values.

Number Input

A numeric input with spin buttons.

<div style="display: flex; flex-direction: column; gap: 1em;">
  <label>Quantity: <input type="number" min="0" max="100" value="1"></label>
  <label>Price: <input type="number" min="0" step="0.01" value="9.99"></label>
  <label>Disabled: <input type="number" value="5" disabled></label>
</div>
Switch - A toggle control that represents an on/off or enabled/disabled state.

Switch Toggle

Toggle switches for on/off states.

<div style="display: flex; flex-direction: column; gap: 1em;">
  <label style="display: flex; align-items: center; gap: 0.75em;">
    <span role="switch" aria-checked="false" tabindex="0"></span>
    Off
  </label>
  <label style="display: flex; align-items: center; gap: 0.75em;">
    <span role="switch" aria-checked="true" tabindex="0"></span>
    On
  </label>
  <label style="display: flex; align-items: center; gap: 0.75em;">
    <span role="switch" aria-checked="false" aria-disabled="true" tabindex="-1"></span>
    Disabled
  </label>
</div>
Table - A structured grid of data organized in rows and columns for displaying information.

Basic Table

A data table with headers and rows.

User Data
Name Email Role
Alice Johnson alice@example.com Admin
Bob Smith bob@example.com User
Carol White carol@example.com Moderator
<table>
  <caption>User Data</caption>
  <thead>
    <tr>
      <th>Name</th>
      <th>Email</th>
      <th>Role</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Alice Johnson</td>
      <td>alice@example.com</td>
      <td>Admin</td>
    </tr>
    <tr>
      <td>Bob Smith</td>
      <td>bob@example.com</td>
      <td>User</td>
    </tr>
    <tr>
      <td>Carol White</td>
      <td>carol@example.com</td>
      <td>Moderator</td>
    </tr>
  </tbody>
</table>
Tabs - A set of layered content panels where only one panel is displayed at a time. Uses CSS-only functionality with radio inputs for state management.

Horizontal Tabs

Standard horizontal tabs with radio inputs for CSS-only state management.

General Settings

Configure your general application settings here.

Profile Settings

Update your profile information and preferences.

Security Settings

Manage your password and security options.

<div>
  <ul role="tablist" aria-label="Settings tabs">
    <li><input type="radio" name="tabs-demo" id="tab1" checked /><label for="tab1" id="tab1-label">General</label></li>
    <li><input type="radio" name="tabs-demo" id="tab2" /><label for="tab2" id="tab2-label">Profile</label></li>
    <li><input type="radio" name="tabs-demo" id="tab3" /><label for="tab3" id="tab3-label">Security</label></li>
  </ul>
  <div role="group" aria-label="Tab panels">
    <div role="tabpanel" aria-labelledby="tab1-label">
      <h4>General Settings</h4>
      <p>Configure your general application settings here.</p>
    </div>
    <div role="tabpanel" aria-labelledby="tab2-label">
      <h4>Profile Settings</h4>
      <p>Update your profile information and preferences.</p>
    </div>
    <div role="tabpanel" aria-labelledby="tab3-label">
      <h4>Security Settings</h4>
      <p>Manage your password and security options.</p>
    </div>
  </div>
</div>

Vertical Tabs

Vertical tab orientation for sidebar-style navigation. Use aria-orientation='vertical'.

Dashboard

Welcome to your dashboard overview.

Analytics

View your analytics and metrics here.

Reports

Generate and download reports.

<div style="display: flex;">
  <ul role="tablist" aria-label="Navigation tabs" aria-orientation="vertical">
    <li><input type="radio" name="vtabs-demo" id="vtab1" checked /><label for="vtab1" id="vtab1-label">Dashboard</label></li>
    <li><input type="radio" name="vtabs-demo" id="vtab2" /><label for="vtab2" id="vtab2-label">Analytics</label></li>
    <li><input type="radio" name="vtabs-demo" id="vtab3" /><label for="vtab3" id="vtab3-label">Reports</label></li>
  </ul>
  <div role="group" aria-label="Tab panels">
    <div role="tabpanel" aria-labelledby="vtab1-label">
      <h4>Dashboard</h4>
      <p>Welcome to your dashboard overview.</p>
    </div>
    <div role="tabpanel" aria-labelledby="vtab2-label">
      <h4>Analytics</h4>
      <p>View your analytics and metrics here.</p>
    </div>
    <div role="tabpanel" aria-labelledby="vtab3-label">
      <h4>Reports</h4>
      <p>Generate and download reports.</p>
    </div>
  </div>
</div>

Tabs with Disabled State

Tabs can be disabled using the disabled attribute on the radio input.

This tab is active and selectable.

This content is not accessible.

This tab is also available for selection.

<div>
  <ul role="tablist" aria-label="Feature tabs">
    <li><input type="radio" name="dtabs-demo" id="dtab1" checked /><label for="dtab1" id="dtab1-label">Active</label></li>
    <li><input type="radio" name="dtabs-demo" id="dtab2" disabled /><label for="dtab2" id="dtab2-label">Disabled</label></li>
    <li><input type="radio" name="dtabs-demo" id="dtab3" /><label for="dtab3" id="dtab3-label">Available</label></li>
  </ul>
  <div role="group" aria-label="Tab panels">
    <div role="tabpanel" aria-labelledby="dtab1-label">
      <p>This tab is active and selectable.</p>
    </div>
    <div role="tabpanel" aria-labelledby="dtab2-label">
      <p>This content is not accessible.</p>
    </div>
    <div role="tabpanel" aria-labelledby="dtab3-label">
      <p>This tab is also available for selection.</p>
    </div>
  </div>
</div>
Toolbar - A container for grouping related controls such as buttons and menu items.

Basic Toolbar

A horizontal toolbar with grouped controls.

<div role="toolbar" aria-label="Text formatting">
  <div role="group" aria-label="Text style">
    <button data-variant="ghost">B</button>
    <button data-variant="ghost">I</button>
    <button data-variant="ghost">U</button>
  </div>
  <span role="separator"></span>
  <div role="group" aria-label="Alignment">
    <button data-variant="ghost">Left</button>
    <button data-variant="ghost">Center</button>
    <button data-variant="ghost">Right</button>
  </div>
  <span role="separator"></span>
  <button data-variant="ghost">Link</button>
</div>

Vertical Toolbar

A vertical toolbar using aria-orientation.

<div role="toolbar" aria-label="Tools" aria-orientation="vertical">
  <button data-variant="ghost">Select</button>
  <button data-variant="ghost">Move</button>
  <span role="separator"></span>
  <button data-variant="ghost">Draw</button>
  <button data-variant="ghost">Erase</button>
</div>
Tooltip - A contextual popup that displays descriptive information about an element on hover or focus.

Data Attribute Tooltip

CSS-only tooltips using data-tooltip attribute.

<div style="display: flex; gap: 2em; padding: 2em;">
  <button data-tooltip="Save your changes">Save</button>
  <button data-tooltip="Delete this item" data-tooltip-position="bottom">Delete</button>
  <button data-tooltip="Edit content" data-tooltip-position="right">Edit</button>
</div>

ARIA Tooltip

Tooltip with proper ARIA role for accessibility.

Additional information about this button
<div style="position: relative; display: inline-block;">
  <button aria-describedby="tooltip1">Hover for info</button>
  <span role="tooltip" id="tooltip1" style="top: 100%; left: 50%; transform: translateX(-50%); margin-top: 0.5em;">
    Additional information about this button
  </span>
</div>
Treegrid - A grid widget that combines the features of a tree and a data grid.

Basic Treegrid

A hierarchical data grid with expandable rows.

Name Size Modified
Documents Today
Report.pdf 2.4 MB Yesterday
Notes.txt 12 KB Last week
<div role="treegrid" aria-label="File browser">
  <div role="row">
    <span role="columnheader">Name</span>
    <span role="columnheader">Size</span>
    <span role="columnheader">Modified</span>
  </div>
  <div role="row" aria-level="1" aria-expanded="true" tabindex="0">
    <span role="gridcell">Documents</span>
    <span role="gridcell">—</span>
    <span role="gridcell">Today</span>
  </div>
  <div role="row" aria-level="2" tabindex="-1">
    <span role="gridcell">Report.pdf</span>
    <span role="gridcell">2.4 MB</span>
    <span role="gridcell">Yesterday</span>
  </div>
  <div role="row" aria-level="2" tabindex="-1">
    <span role="gridcell">Notes.txt</span>
    <span role="gridcell">12 KB</span>
    <span role="gridcell">Last week</span>
  </div>
</div>
Treeview - A hierarchical list that can have nested groups of items that can be expanded or collapsed.

Basic Treeview

A hierarchical tree with expandable nodes.

  • Documents
    • Personal
  • Downloads
<ul role="tree" aria-label="File system">
  <li role="treeitem" aria-expanded="true" tabindex="0">
    Documents
    <ul role="group">
      <li role="treeitem" aria-expanded="false" tabindex="-1">
        Work
        <ul role="group">
          <li role="treeitem" tabindex="-1">Report.docx</li>
          <li role="treeitem" tabindex="-1">Presentation.pptx</li>
        </ul>
      </li>
      <li role="treeitem" tabindex="-1">Personal</li>
    </ul>
  </li>
  <li role="treeitem" aria-expanded="false" tabindex="-1">
    Pictures
    <ul role="group">
      <li role="treeitem" tabindex="-1">Vacation</li>
      <li role="treeitem" tabindex="-1">Family</li>
    </ul>
  </li>
  <li role="treeitem" aria-selected="true" tabindex="-1">Downloads</li>
</ul>
Window Splitter - A movable divider that separates two sections and allows resizing them.

Horizontal Splitter

A vertical divider between two horizontal panes.

Left Pane
Right Pane
<div style="display: flex; height: 150px; border: 1px solid var(--surface_muted); border-radius: 0.5em; overflow: hidden;">
  <div style="flex: 1; padding: 1em; background: var(--surface_raised);">Left Pane</div>
  <div role="separator" aria-orientation="vertical" aria-valuenow="50" tabindex="0"></div>
  <div style="flex: 1; padding: 1em;">Right Pane</div>
</div>

Vertical Splitter

A horizontal divider between two vertical panes.

Top Pane
Bottom Pane
<div style="display: flex; flex-direction: column; height: 200px; border: 1px solid var(--surface_muted); border-radius: 0.5em; overflow: hidden;">
  <div style="flex: 1; padding: 1em; background: var(--surface_raised);">Top Pane</div>
  <div role="separator" aria-orientation="horizontal" aria-valuenow="50" tabindex="0"></div>
  <div style="flex: 1; padding: 1em;">Bottom Pane</div>
</div>