Files
webawesome/docs/docs/utilities/native.md
Cory LaViska b96c3f318b Simplify native styles (#993)
* move print styles

* begin native styles split

* unsplit button styles 😓

* unsplit callout; remove .wa-callout

* merge forms

* remove unused

* remove unused

* unsplit checkbox

* remove old astro config

* remove overflow

* unsplit slider

* fix tooltip position in RTL

* unsplit radio

* move required light DOM styles to <wa-page>

* remove unused file

* remove unused import

* remove

* goodbye

* fix examples

* unsplit dialog

* unsplit select

* remove select

* unsplit input

* unsplit details

* update

* update comment

* update textarea

* combine native docs; improvements

* update

* reorg and fix headings

* fix details summary padding; fixes #684

* update

* fix native details summary padding; fixes #684

* #684

* remove passthrough style nonsense

* it's CSS not JS

* fix details in sidebar

* add spacing in native buttons for icons

* whitespace

* update docs

* remove button group util

* remove shadow folder, add component folder

* layerize

* default border radius

* remove color contrast script from dist

* add term

* layerize themes + color folders

* reorder

* remove radio button; #504

* remove visual tests

* remove visual tests

* remove unused stylesheet

* make search smarter

* add radio styles

* Fix filled textareas

* re-introduce visual tests (with adjustments)

* fix button appearances

* fix textarea focus styles

* re-introduce appearance classes

* remove 'native styles' note from component pages

* fix checked radio styles

* touch up callout styles

* remove errant `.wa-tag`

* scope appearance classes to relevant elements

* more visual test cases

* fix details borders

* minor visual tests reorg

* add `--box-shadow` to buttons

* fix Awesome theme

* use same layer for all themes (allows unset properties to inherit from Default theme)

* fix box-shadow in wa-textarea

* set button box shadow to `initial`

* fix Active theme

* fix Brutalist theme

* fix Glossy theme

* fix Matter theme (mostly)

* fix Playful theme

* fix Premium theme

* fix Shoelac theme

* fix Tailspin theme

* fix custom radio button styles

* fix links to native styles doc

---------

Co-authored-by: lindsaym-fa <dev@lindsaym.design>
2025-05-29 13:10:53 -04:00

12 KiB

title, description, layout
title description layout
Native Styles Native styles apply your theme to native HTML elements so they match the look and feel of Web Awesome components. page-outline

Web Awesome Native Styles

Web Awesome provides optional Native Styles that make native HTML elements look good so you can continue using what you know and gradually adopt Web Awesome as you see fit.

Installation

To use all Web Awesome page styles (including utilities), include the following stylesheet in your project:

<link rel="stylesheet" href="{% cdnUrl 'styles/webawesome.css' %}" />

Or, to only include styles for native elements:

<link rel="stylesheet" href="{% cdnUrl 'styles/native.css' %}" />

Elements

Headings

Semantic heading elements with proper hierarchy and styling.

<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>

Paragraphs

Standard paragraph text with optimal spacing and readability.

<p>Vel risus commodo viverra maecenas accumsan lacus vel facilisis volutpat. Amet mauris commodo quis imperdiet. Bibendum ut tristique et egestas quis ipsum suspendisse. Sit amet nulla facilisi morbi tempus iaculis urna id volutpat.</p>

<p>Cras pulvinar mattis nunc sed blandit libero. Facilisis magna etiam tempor orci. Scelerisque eleifend donec pretium vulputate sapien nec. Donec et odio pellentesque diam volutpat commodo sed egestas egestas. Mauris rhoncus aenean vel elit scelerisque mauris pellentesque.</p>

Blockquotes

Styled quotations that stand out from regular text.

<blockquote>
  What is a Web year now, about three months? And when people can browse around, discover new things, and download them fast, when we all have agents - then Web years could slip by before human beings can notice.<br><br>
  — Tim Berners-Lee
</blockquote>

Lists

Organized content in bulleted or numbered format with proper nesting support.

<ul>
  <li>List item 1</li>
  <li>List item 2
    <ul>
      <li>Subitem a</li>
      <li>Subitem b</li>
    </ul>
  </li>
  <li>List item 3</li>
</ul>

<ol>
  <li>List item 1</li>
  <li>List item 2
    <ul>
      <li>Subitem a</li>
      <li>Subitem b</li>
    </ul>
  </li>
  <li>List item 3</li>
</ol>

Definition Lists

Term and definition pairs for glossaries and descriptions.

<dl>
  <dt>Definition 1</dt>
  <dd>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</dd>
  <dt>Definition 2</dt>
  <dd>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</dd>
  <dt>Definition 3</dt>
  <dd>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</dd>
</dl>

Details

Collapsible content sections with expand/collapse functionality.

<details>
  <summary>Tincidunt nunc pulvinar</summary>
  <p>Ut lectus arcu bibendum at varius. Convallis a cras semper auctor neque vitae. Odio pellentesque diam volutpat commodo sed egestas. Amet dictum sit amet justo donec enim diam vulputate ut.</p>
</details>

Dialog

Modal dialog windows for alerts, confirmations, and overlays.

<dialog id="dialog-example">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
	<button type="button">Close</button>
</dialog>

<button>Open Dialog</button>

<script>
  const dialog = document.querySelector('#dialog-example');
  const openButton = dialog.nextElementSibling;
  const closeButton = dialog.querySelector('button');

  openButton.addEventListener('click', () => dialog.showModal());
  closeButton.addEventListener('click', () => dialog.close());
</script>

Inline Text

Various text formatting elements for emphasis and semantic meaning.

<div class="two-columns">
  <p><strong>Bold</strong></p>
  <p><em>Italics</em></p>
  <p><u>Underline</u></p>
  <p><del>Deleted</del></p>
  <p><ins>Inserted</ins></p>
  <p><s>Strike-through</s></p>
  <p><small>Small</small></p>
  <p><span>Text <sub>Sub</sub></span></p>
  <p><span>Text <sup>Sup</sup></span></p>
  <p><abbr title="Abbreviation">Abbr.</abbr></p>
  <p><kbd>Keyboard</kbd></p>
  <p><mark>Highlighted</mark></p>
  <p><a href="#">Link text</a></p>
  <p><code>Inline code</code></p>
</div>

Code Blocks

Formatted code snippets with proper syntax styling.

// do a thing
export function thing() {
  return true;
}

Images

Responsive images with proper scaling and styling.

A gray kitten lays next to a toy

Progress Bars

Visual indicators for task completion and loading states.

<progress value="40" max="100"></progress>
<br>
<progress></progress>

Tables

Structured data presentation with clean styling and optional zebra striping.

<table>
  <caption>I'm just a table</caption>
  <thead>
    <tr>
      <th>Column 1</th>
      <th>Column 2</th>
      <th>Column 3</th>
      <th>Column 4</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
  </tbody>
</table>

You can use the wa-zebra-rows class to add alternating row colors to your table:

<table class="wa-zebra-rows">
  <caption>I'm just a table</caption>
  <thead>
    <tr>
      <th>Column 1</th>
      <th>Column 2</th>
      <th>Column 3</th>
      <th>Column 4</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
  </tbody>
</table>

Form Controls

Buttons

Use the variant utility classes to set the button's semantic variant.

<button class="wa-neutral"><wa-icon name="home"></wa-icon> Neutral</button>
<button class="wa-brand">Brand</button>
<button class="wa-success">Success</button>
<button class="wa-warning">Warning</button>
<button class="wa-danger">Danger</button>

Use the appearance utility classes to change the button's visual appearance:

<div style="margin-block-end: 1rem;">
  <button class="wa-accent wa-outlined wa-neutral">A + O</button>
  <button class="wa-accent wa-neutral">Accent</button>
  <button class="wa-outlined wa-neutral">Outlined</button>
  <button class="wa-filled wa-outlined wa-neutral">F + O</button>
  <button class="wa-filled wa-neutral">Filled</button>
  <button class="wa-plain wa-neutral">Plain</button>
</div>
<div style="margin-block-end: 1rem;">
  <button class="wa-accent wa-outlined wa-brand">A + O</button>
  <button class="wa-accent wa-brand">Accent</button>
  <button class="wa-outlined wa-brand">Outlined</button>
  <button class="wa-filled wa-outlined wa-brand">F + O</button>
  <button class="wa-filled wa-brand">Filled</button>
  <button class="wa-plain wa-brand">Plain</button>
</div>
<div style="margin-block-end: 1rem;">
  <button class="wa-accent wa-outlined wa-success">A + O</button>
  <button class="wa-accent wa-success">Accent</button>
  <button class="wa-outlined wa-success">Outlined</button>
  <button class="wa-filled wa-outlined wa-success">F + O</button>
  <button class="wa-filled wa-success">Filled</button>
  <button class="wa-plain wa-success">Plain</button>
</div>
<div style="margin-block-end: 1rem;">
  <button class="wa-accent wa-outlined wa-warning">A + O</button>
  <button class="wa-accent wa-warning">Accent</button>
  <button class="wa-outlined wa-warning">Outlined</button>
  <button class="wa-filled wa-outlined wa-warning">F + O</button>
  <button class="wa-filled wa-warning">Filled</button>
  <button class="wa-plain wa-warning">Plain</button>
</div>
<div>
  <button class="wa-accent wa-outlined wa-danger">A + O</button>
  <button class="wa-accent wa-danger">Accent</button>
  <button class="wa-outlined wa-danger">Outlined</button>
  <button class="wa-filled wa-outlined wa-danger">F + O</button>
  <button class="wa-filled wa-danger">Filled</button>
  <button class="wa-plain wa-danger">Plain</button>
</div>

Use the size utility classes to change a button's size.

<button class="wa-size-s">Small</button>
<button class="wa-size-m">Medium</button>
<button class="wa-size-l">Large</button>

Use the wa-pill class to give buttons rounded edges.

<button class="wa-size-s wa-pill">Small</button>
<button class="wa-size-m wa-pill">Medium</button>
<button class="wa-size-l wa-pill">Large</button>

Checkboxes

Multi-select form controls with checked, indeterminate, and disabled states.

<label><input type="checkbox" checked> Checked</label><br>
<label><input type="checkbox" class="indeterminate"> Indeterminate</label><br>
<label><input type="checkbox" disabled> Disabled</label>

<script>
  document.querySelector(".indeterminate").indeterminate = true;
</script>

Radios

Single-select form controls for mutually exclusive choices.

You can wrap native radios in a flex container to give them a horizontal or vertical orientation with even spacing. The convenience wa-cluster and wa-stack utilities make this easy.

<div class="wa-cluster">
  <label><input type="radio" name="b" value="1" checked> Option 1</label>
  <label><input type="radio" name="b" value="2"> Option 2</label>
  <label><input type="radio" name="b" value="3"> Option 3</label>
</div>

<div class="wa-stack" style="margin-block-start: var(--wa-space-2xl);">
  <label><input type="radio" name="g" value="1" checked> Option 1</label>
  <label><input type="radio" name="g" value="2"> Option 2</label>
  <label><input type="radio" name="g" value="3"> Option 3</label>
</div>

Selects

Dropdown menus for choosing from a list of options.

<label>Select
  <select id="select">
    <option value="option-1">Option 1</option>
    <option value="option-2">Option 2</option>
    <option value="option-3">Option 3</option>
  </select>
</label>

Sliders

Range inputs for selecting numeric values within a specified range.

<label>Select a value: <input type="range"></label>

Text Fields

Various input types for collecting user text and data.

<label>Text <input type="text" placeholder="placeholder"></label>

<label>Number <input type="number"></label>

<label>Password <input type="password" required></label>

<label>Email <input type="email"></label>

<label>Search <input type="search"></label>

<label>Telephone <input type="tel"></label>

<label>URL <input type="url"></label>

Add the wa-pill class to an <input> to make it pill-shaped.

<label>Input <input type="text" placeholder="placeholder" class="wa-pill"></label>

Color Pickers

Visual color selection interface with hex value input.

<label>Input (color) <input type="color" value="#ff0066"></label>

Date & Time Pickers

Specialized inputs for selecting dates, times, and datetime values.

<label>Input (datetime-local) <input type="datetime-local"></label>

<label>Input (date) <input type="date"></label>

<label>Input (time) <input type="time"></label>

Textareas

Multi-line text input fields for longer content.

<label>Textarea <textarea placeholder="Type something"></textarea></label>