Pure, the Lightweight and Mobile Friendly Solution
You want to make the best possible project, but you keep on adding framework after framework until your project is so big and bulky that no one wants to use it, let alone have it waste space on their device. But how can you build a lightweight and attention-grabbing RhoMobile App?
One answer might be Pure.css, a lightweight CSS framework that provides appealing layouts and stylings for native HTML elements. Pure includes some of the most common UI components, but none of the excess baggage. The entire set of modules in Pure clocks in at 4.0KB minified and gzipped.
Pure is responsive out of the box and was designed with mobile in mind. Elements look great on any screen, automatically adjusting to fit whatever device or monitor is in use.
You can include Pure in your projects with the following line:
http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
The Grid System
- The grid system in Pure differs from that of other frameworks such as Bootstrap and it is powerful and easy to work with once you get past the basics. There are a few things to keep in mind when starting:
- Pure Grids consist of two types of classes: the grid class (pure-g) and unit classes (pure-u or pure-u-*)
- Units have various class names that represent their widths. For example, pure-u-1-2 has a width of 50 percent, whereas pure-u-1-5 would have a width of 20 percent. Your columns can get as small as pure-u-1-24, so you have plenty of options for customization.
- Child elements contained within an element with a pure-g class name must be a grid unit with a pure-u or pure-u-* class name
- All content which is visible to people needs to be contained inside a grid unit. This ensures that the content will be rendered properly.
Here’s an example of a pure grid with four columns that are each one-fourth width.
div class="pure-g">
div class="pure-u-1-4">p>Fourthsp>div>
div class="pure-u-1-4">p>Fourthsp>div>
div class="pure-u-1-4">p>Fourthsp>div>div class="pure-u-1-4">p>Fourthsp>div>
div>
Pure Grids are useful when you want to present pictures, text boxes, or any other form of information in a structured manner. You could create a picture gallery, a contacts page, or anything else that comes to mind.
Pure Responsive Grid
Pure has a mobile-first responsive grid system that can be used declaratively through CSS class names. It's a robust and flexible grid that builds on top of the default grid. You can include this responsive grid system in your projects by including the following
tag in your page:
link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/grids-responsive-min.css">
Pure Responsive Grid allows you to include additional class names like pure-u-md-2-5 to control the width of different elements at specific breakpoints. Take a look at the following HTML:
One
Two
Three
The above code does the following: When the screen size is smaller than 568px, all divs will be 100 percent wide. When the screen size is above the medium screen category (768px) the first div is set to a width of 25 percent while others are 20 percent wide each.
An example of a responsive Grid:
Responsive Images
When using Responsive Grids, you'll want your images to be fluid as well so they grow and shrink with the content while maintaining the correct ratio. To do this, just add the .pure-img class on them.
For more details about the grid system, you can check out Pure’s documentation.
Menus Galore
Pure offers a variety of different menu types ranging from drop-down menus to vertical menus with submenus. Minimal styling and use of low specificity selectors make it a lot easier to customize the menus.
Vertical Menus
The default menu type. Here is the code to create a vertical menu:
You can easily change this vertical menu to a horizontal menu or scrollable menu by adding the class name pure-menu-horizontal and pure-menu-scrollable respectively to the pure-menu
Drop Down Menus
Creating a dropdown menu requires small changes in the markup. You need to add the class name pure-menu-has-children to the appropriate menu item. To display the submenu on hover, include the class name pure-menu-allow-hover. The code snippet below should help clear things up:
Example of Dropdown menu:
You can also include this example script written in vanilla JavaScript to make the menu more accessible. It provides ARIA support, submenu arrow key navigation, and menu dismissal based on outside events.
Vertical Menu with Submenus
The same construct used to create dropdowns works in vertical menus as well. You may nest submenus, but keep in mind that complex menus can present usability challenges on small screens.
For more details about the menus, check out Pure’s documentation.
Purest of Forms
Pure’s form options include plain forms, forms within grids, grouped inputs, and more.
Default Forms
To create a form with Pure you need to add the class name pure-form to the
Which would create:
To create a stacked form with input elements below the labels, add the pure-form-stacked class name to a
Jake Bernstein