```98.css```
98.css

原始链接: https://jdan.github.io/98.css/#status-bar

**98.css** 是一个轻量级的纯 CSS 设计系统,旨在帮助开发者忠实还原经典的 Windows 98 用户界面。由于它完全依赖 CSS 样式而非 JavaScript,因此它与框架无关,并兼容 React、Vue 或原生 HTML/JS 等各类工具。 该库强调语义化 HTML 和无障碍访问,需要使用标准元素(如 `

相关文章

原文
98.css - A design system for building faithful recreations of old UIs

A design system for building faithful recreations of old UIs.

npm gzip size

Intro

98.css is a CSS library for building interfaces that look like Windows 98. See more on GitHub.

This library relies on the usage of semantic HTML. To make a button, you'll need to use a <button>. Input elements require labels. Icon buttons rely on aria-label. This page will guide you through that process, but accessibility is a primary goal of this project.

You can override many of the styles of your elements while maintaining the appearance provided by this library. Need more padding on your buttons? Go for it. Need to add some color to your input labels? Be our guest.

This library does not contain any JavaScript, it merely styles your HTML with some CSS. This means 98.css is compatible with your frontend framework of choice.

Here is an example of 98.css used with React, and an example with vanilla JavaScript. The fastest way to use 98.css is to import it from unpkg.

<link
  rel="stylesheet"
  href="https://unpkg.com/98.css"
>

You can install 98.css from the GitHub releases page, or from npm.

npm install 98.css

Components

Button

A command button, also referred to as a push button, is a control that causes the application to perform some action when the user clicks it.
— Microsoft Windows User Experience p. 160

A standard button measures 75px wide and 23px tall, with a raised outer and inner border. They are given 12px of horizontal padding by default.

You can add the class default to any button to apply additional styling, useful when communicating to the user what default action would happen in the active window if the Enter key was pressed on Windows 98.

Show code
<button class="default">OK</button>

When buttons are clicked, the raised borders become sunken. The following button is simulated to be in the pressed (active) state.

Show code
<button>I am being pressed</button>

Disabled buttons maintain the same raised border, but have a "washed out" appearance in their label.

Show code
<button disabled>I cannot be clicked</button>

Button focus is communicated with a dotted border, set 4px within the contents of the button. The following example is simulated to be focused.

Show code
<button>I am focused</button>

Checkbox

A check box represents an independent or non-exclusive choice.
— Microsoft Windows User Experience p. 167

Checkboxes are represented with a sunken panel, populated with a "check" icon when selected, next to a label indicating the choice.

Note: You must include a corresponding label after your checkbox, using the <label> element with a for attribute pointed at the id of your input. This ensures the checkbox is easy to use with assistive technologies, on top of ensuring a good user experience for all (navigating with the tab key, being able to click the entire label to select the box).

Checkboxes can be selected and disabled with the standard checked and disabled attributes.

When grouping inputs, wrap each input in a container with the field-row class. This ensures a consistent spacing between inputs.

OptionButton

An option button, also referred to as a radio button, represents a single choice within a limited set of mutually exclusive choices. That is, the user can choose only one set of options.
— Microsoft Windows User Experience p. 164

Option buttons can be used via the radio type on an input element.

Option buttons can be grouped by specifying a shared name attribute on each input. Just as before: when grouping inputs, wrap each input in a container with the field-row class to ensure a consistent spacing between inputs.

Option buttons can also be checked and disabled with their corresponding HTML attributes.

GroupBox

A group box is a special control you can use to organize a set of controls. A group box is a rectangular frame with an optional label that surrounds a set of controls.
— Microsoft Windows User Experience p. 189

A group box can be used by wrapping your elements with the fieldset tag. It contains a sunken outer border and a raised inner border, resembling an engraved box around your controls.

You can provide your group with a label by placing a legend element within the fieldset.

TextBox

A text box (also referred to as an edit control) is a rectangular control where the user enters or edits text. It can be defined to support a single line or multiple lines of text.
— Microsoft Windows User Experience p. 181

Text boxes can rendered by specifying a text type on an input element. As with checkboxes and radio buttons, you should provide a corresponding label with a properly set for attribute, and wrap both in a container with the field-row class.

Additionally, you can make use of the field-row-stacked class to position your label above the input instead of beside it.

To support multiple lines in the user's input, use the textarea element instead.