One UI Web
repository·master·Indexed 42 days ago
https://github.com/samsunginternet/oneui-webA CSS framework inspired by the Samsung One UI interface, designed to simplify the creation of mobile web applications with a consistent and optimized user experience for Samsung mobile devices. Version 1.0.0 includes components such as appbars, badges, bubbles, dialogs, and various input elements like checkboxes, radio buttons, and sliders.
What's inside One UI Web
- One UI Web is a framework inspired by Samsung's One UI design language. It is designed to simplify the creation of mobile web applications that provide a One UI user experience, optimizing web apps with the specific look and feel of Samsung's One UI. The framework aims to provide a consistent, comfortable, and unified user experience, particularly for Galaxy devices and larger mobile screens.
Accessibility principles in One UI Web
masterOne UI Web is designed based on the One UI Design Accessibility Principles to ensure an inclusive user experience. The library aims to meet the Web Content Accessibility Guidelines (WCAG).
When building with One UI Web, the components follow these core design pillars:
- Consideration: Empathetic and detailed design for all users.
- Comprehensive: Balanced and equal design for all users, ensuring users with disabilities do not experience difficulty or discrimination.
- Coherence: Consistent design experience across products and features.
- Co-creation: Designing through collaboration with professionals and communities involving users with disabilities.
Accessibility compliance levels in One UI Web
masterOne UI Web components are designed to meet WCAG Level AA compliance.
For context, WCAG defines three levels of compliance:
- Level A: Basic accessibility features. Without these, assistive technology may fail to read or operate the page.
- Level AA: The target level for One UI Web. It addresses common barriers for disabled users and provides ideal support.
- Level AAA: High-level support, typically reserved for specialized audiences.
Each component in One UI Web has been tested (e.g., using tools like
achecker.ca) to ensure compliance across three main areas:- Content: Providing text alternatives for non-text content to ensure readability.
- Navigation: Ensuring all functionality is available via keyboard and content is easily discoverable.
- Compatibility: Maximizing compatibility with screen readers and future browsers.
Understand the One UI Web theme structure
masterThemes in One UI Web are implemented using CSS
Custom Properties(CSS variables). A theme is structured in layers: first, a color palette is defined, and then these palette colors are assigned to functional variables. This hierarchy allows One UI Web controls to remain consistent and makes the UI easy to update.The structure follows this pattern:
- Color Palette: Raw color values (e.g.,
--palette-var1). - Main Theme Variables: Functional roles like text or primary accents (e.g.,
--variable1). - Backgrounds: Colors for UI surfaces (e.g.,
--background1). - Accents: Colors for interactive elements (e.g.,
--accent1). - On Top Colors: Colors intended to be used on top of specific backgrounds (e.g.,
--on-variable1). - Borders: Colors for UI borders (e.g.,
--border1).
:root{ /*color palette*/ --palette-var1: #FFFFFF; --palette-var2: #EEEEEE; /* ... */ --palette-varn: #000000; /*main theme variables*/ --variable1: var(--palette-var1); /* ... */ /*backgrounds*/ --background1: var(--palette-var1); /* ... */ /*accents*/ --accent1: var(--palette-var1); /* ... */ /*on top colors*/ --on-variable1: var(--palette-var1); /* ... */ /*borders*/ --border1: var(--palette-var1); /* ... */ }- Color Palette: Raw color values (e.g.,
Quickstart with One UI Web via CDN
masterTo quickly start a project without managing local files, include the One UI CSS via the JSDelivr CDN. Use the following HTML structure to ensure the layout is correctly initialized with the
containerclass and the requiredoui-viewingandoui-interactionareas.<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Hello, world!</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/samsunginternet/OneUI-Web/oui-css/oui.css"> </head> <body> <main class="container"> <div class="oui-viewing"> <!-- Viewing area --> </div> <div class="oui-interaction"> <!-- Interaction area --> </div> </main> </body> </html>Quickstart One UI Web using the CDN
masterTo quickly integrate One UI Web into your project without downloading files, include the CSS stylesheet via the JSDelivr CDN in your
<head>section. Use the following HTML structure to set up the basic layout with a container and the required viewing/interaction areas.<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Hello, world!</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/samsunginternet/OneUI-Web/oui-css/oui.css"> </head> <body> <main class="container"> <div class="oui-viewing"> <!-- Viewing area --> </div > <div class="oui-interaction"> <!-- Interaction area --> </div > </main> </body> </html>Get started with One UI Web
masterTo begin using One UI Web in your project, follow the step-by-step instructions provided in the QuickStart guide. This guide covers the requirements and methods for including the framework in your web application.
See the [QuickStart Page](/getting-started/quickstart) for setup instructions.Use the Dialog component
masterThe
oui-dialogcomponent is used to display popup dialogs to users. To ensure a proper user experience, it is recommended to include anoui-dialog-maskelement, which dims the background and prevents the underlying page from scrolling while the dialog is active.Component Structure
oui-dialog: The main container for the popup.oui-dialog-header: The header section, typically used for the dialog title.oui-dialog-description: The container for the main body content of the dialog.oui-dialog-action: A container for action items (buttons or links).oui-dialog-action-link: Used for individual buttons or links within the action area.oui-dialog-divider: A visual divider used to separate different types of actions (e.g., separating a primary button from a secondary link).
<div class="oui-dialog-mask"></div> <div class="oui-dialog"> <div class="oui-dialog-header"> Dialog Title </div> <div class="oui-dialog-description"> <p>Main content goes here.</p> </div> <div class="oui-dialog-action"> <a href="#" class="oui-dialog-action-link">Close</a> <div class="oui-dialog-divider"></div> <a href="#" class="oui-dialog-action-link">More info</a> </div> </div>Create Buttons
masterButtons are created by adding the
oui-buttonclass to an<input type="button">element.Default Button
Use only the
oui-buttonclass.Active Button
To represent an active state, add the
oui-button--activemodifier class to theoui-buttonclass.<!-- Default button --> <input type="button" value="button" class="oui-button"> <!-- Active button --> <input type="button" value="Active button" class="oui-button oui-button--active">Run the documentation locally
masterThe project documentation is built with DocsifyJS. To run a local instance of the documentation, follow these steps:
- Install the Docsify CLI globally:
npm i docsify-cli -g
2. Navigate to the `gh-page` branch and start the local server: ```bash docsify serve- Access the documentation in your browser at
http://localhost:3000.
npm i docsify-cli -g docsify serve- Install the Docsify CLI globally:
Create a Toast component
masterUse the
oui-toastclass to create a toast notification that mimics the native Android Toast appearance. The component requires a specific HTML structure:oui-toast: The main container for the toast.oui-toast-text: A child element (typically a<span>) that holds the message text to be displayed.
<div class="oui-toast"> <span class="oui-toast-text">Hello this is a toast</span> </div>Include required scripts for Menu functionality
masterTo enable keyboard shortcuts (navigating and opening/closing the dialog) and focus effects (when tabbing through elements), you must include the following scripts. These only need to be included once per page.
Note: The
focus-visible.jspolyfill is required for proper focus styling.<script src="https://cdn.jsdelivr.net/gh/SamsungInternet/OneUI-Web@master/oui-css/scripts/polyfill/focus-visible.js" defer></script> <script src="https://cdn.jsdelivr.net/gh/SamsungInternet/OneUI-Web@master/oui-css/scripts/oui.js" defer></script>