Getting Started
Practical for projects of any size.
Hydrogen is a lightweight modular CSS foundation designed for minimalists, with a powerful collection of components and utility classes. The aim of this project to allow for beautiful front-end's to be developed quickly.
You can starting working with Hydrogen in multiple ways. The option with least resistance is a <link>
referencing the free unpkg CDN.
CDN
<link rel="stylesheet" href="https://unpkg.com/hydrogen-css"/>
NPM
npm install hydrogen-css
Base
A minimal reset to create cross-browser consistency.
Hydrogen includes a minimal css reset to reduce browser inconsistencies in things like default line heights, margins and font sizes of headings etc.
Explicit font sizes for headings to ensure consistent rendering. For example, without explicit font sizes, the user agent stylesheet will apply differing sizes to headings within a <section>
.
All sizing within Hydrogen is done using rem
. All rem
units are converted to base 16, so 1rem
is equal to 16px
.
Typography
em
based progressive sizing.
By default, all headings, paragraphs, and code use system fonts, using the most modern one available on a user's operating system. All font-sizes are based on em
units.
Headings
H1 Heading
H2 Heading
H3 Heading
H4 Heading
H5 Heading
H6 Heading
Paragraph
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lists
- Lorem ipsum
- Lorem ipsum
- Lorem ipsum
- Lorem ipsum
- Lorem ipsum
- Lorem ipsum
Description List
- Lorem
- Ipsum
- Lorem
- Ipsum
Buttons
A perfect base for beautiful buttons.
Hydrogen offers two styles of button, bordered and filled. The default .h-btn
class is combined with .h-btn-fill
to create a filled button. The styles are intended to serve as a base and can easily be overriden.
<button class="h-btn">Button</button>
<button class="h-btn" disabled>Disabled Button</button>
<button class="h-btn h-btn-fill">Fill Button</button>
<button class="h-btn h-btn-fill" disabled>Disabled Fill Button</button>
Tables
Elegant override for default table styles.
To override the default user agent table styles, simply append the .h-tbl
class to the <table>
element. To add striped rows, also append the .h-tbl-striped
class.
# | Header | Header | Header | Header |
---|---|---|---|---|
1,001 | Lorem | ipsum | dolor | sit |
1,002 | amet | consectetur | adipiscing | elit |
1,003 | Integer | nec | odio | Praesent |
<table class="h-tbl">
<thead>
<tr>
<th>#</th>
<th>Header</th>
<th>Header</th>
<th>Header</th>
<th>Header</th>
</tr>
</thead>
<tbody>
<tr>
<td>1,001</td>
<td>Lorem</td>
<td>ipsum</td>
<td>dolor</td>
<td>sit</td>
</tr>
<tr>
<td>1,002</td>
<td>amet</td>
<td>consectetur</td>
<td>adipiscing</td>
<td>elit</td>
</tr>
<tr>
<td>1,003</td>
<td>Integer</td>
<td>nec</td>
<td>odio</td>
<td>Praesent</td>
</tr>
</tbody>
</table>
Menus
Easily create user navigation components.
Foundational styles of both vertical and inline navigation components. By default the .h-menu
class renders a vertical navigation component, to make inline simply append the .h-menu-inline
modifier.
Include the optional .h-menu-heading
element to include a descriptive title.
Vertical Menu
<div class="h-menu">
<span class="h-menu-heading">DEFAULT MENU</span>
<ul class="h-menu-list">
<li class="h-menu-item">
<a href="#" class="h-menu-link">Link</a>
</li>
<li class="h-menu-item">
<a href="#" class="h-menu-link">Link</a>
</li>
<li class="h-menu-item">
<a href="#" class="h-menu-link">Link</a>
</li>
</ul>
</div>
Inline Menu
<div class="h-menu h-menu-inline">
<span class="h-menu-heading">INLINE MENU</span>
<ul class="h-menu-list">
<li class="h-menu-item">
<a href="#" class="h-menu-link">Link</a>
</li>
<li class="h-menu-item">
<a href="#" class="h-menu-link">Link</a>
</li>
<li class="h-menu-item">
<a href="#" class="h-menu-link">Link</a>
</li>
</ul>
</div>
Forms
Simple HTML forms.
By default the .h-form
class renders a stacked form.
Form elements can be combined with grid unit sizes to render fields of specific widths.
<form class="h-form">
<fieldset>
<legend class="h-margin-bottom">A compact inline form</legend>
<label>Email</label>
<input class="h-margin-bottom" type="email" placeholder="Email">
<label>Password</label>
<input class="h-margin-bottom" type="password" placeholder="Password" required="">
<label>Disabled</label>
<input class="h-margin-bottom" type="text" placeholder="Disabled" disabled>
<label for="state">State</label>
<select class="h-margin-bottom" name="state">
<option>
AL
</option>
<option>
CA
</option>
<option>
IL
</option>
</select>
<label class="h-margin-bottom" for="remember">
<input id="remember" type="checkbox"> Remember me
</label>
<button class="h-btn h-btn-fill" type="submit">Sign in</button>
</fieldset>
</form>
Grid
Foundation to build fully custom, responsive grids.
The built-in grid system provides the foundation for fully custom, responsive grids. Choose a width, and the rest is done for you.
Grids blocks are designated using the .h-g
class and grid units .h-u
. To enable gutters (1rem
) simply wrap the grid block in a grid container element using th .h-c
class.
<style>
@media screen and (min-width: 48em){
.main { width: 75%; }
.sidebar { width: 25%; }
}
</style>
<div class="h-c">
<div class="h-g">
<div class="h-u main"> ... </div>
<div class="h-u sidebar"> ... </div>
</div>
</div>
Grid Unit Sizes
A 12th scale responsive grid system.
Hydrogen ships with a mobile-first responsive grid system that can be used declaratively through CSS class names (i.e. .h-u-6-12
represents a unit with 50% width). It's a robust and flexible grid that builds on top of the base grid system.
Grid units used without a media prefix (i.e. "-sm", "-md", "-lg", "-xl") are applied to all screen sizes. Grid units with a media prefixes, are applied to the specified width and above. Breakpoint definitions are outlined below.
Prefix | Applies | Class Name |
---|---|---|
None | All screen sizes | h-u-* |
sm |
≥ 30rem |
h-u-sm-* |
md |
≥ 48rem |
h-u-md-* |
lg |
≥ 64rem |
h-u-lg-* |
xl |
≥ 80rem |
h-u-xl-* |
Responsive Grid Example
The example below leverages Hydrogen's grid unit sizes to create a row with four columns. The columns stack on all screens, take up width: 50%
on small screens, width: 33.333%
on medium-sized screens, and width: 25%
on large screens.
This is done by adding the .h-u-12-12
class for all screens, .h-u-sm-6-12
for small screens, .h-u-md-4-12
for medium-sized screens and .h-u-lg-3-12
for extra large screens. Resize the page to see the grid respond to the screen size.
Lorem Ipsum
Nunc interdum dui urna. Donec at lectus sed nisi tristique imperdiet.
Lorem Ipsum
Nunc interdum dui urna. Donec at lectus sed nisi tristique imperdiet.
Lorem Ipsum
Nunc interdum dui urna. Donec at lectus sed nisi tristique imperdiet.
Lorem Ipsum
Nunc interdum dui urna. Donec at lectus sed nisi tristique imperdiet.
<div class="h-g">
<div class="h-u-12-12 h-u-sm-6-12 h-u-md-4-12 h-u-lg-3-12">...</div>
<div class="h-u-12-12 h-u-sm-6-12 h-u-md-4-12 h-u-lg-3-12">...</div>
<div class="h-u-12-12 h-u-sm-6-12 h-u-md-4-12 h-u-lg-3-12">...</div>
<div class="h-u-12-12 h-u-sm-6-12 h-u-md-4-12 h-u-lg-3-12">...</div>
</div>
Utilities
Utility classes for common css tasks.
Display
.h-display-block
(setsdisplay: block;
).h-display-inline
(setsdisplay: inline;
).h-display-inline-block
(setsdisplay: inline-block;
).h-display-none
(setsdisplay: none;
)
Flexbox
.h-flex
(setsdisplay: flex;
).h-flex-column
(setsflex-direction: column;
).h-flex-row
(setsflex-direction: row;
).h-flex-reverse
(setsflex-direction: reverse;
).h-flex-nowrap
(setsflex-wrap: nowrap;
).h-flex-wrap
(setsflex-wrap: wrap;
).h-flex-align-center
(setsalign-items: center;
).h-flex-align-end
(setsalign-items: flex-end;
).h-flex-align-start
(setsalign-items: flex-start;
).h-flex-align-self-center
(setsalign-self: center;
).h-flex-align-self-end
(setsalign-self: flex-end;
).h-flex-align-self-start
(setsalign-self: flex-start;
).h-flex-justify-center
(setsjustify-content: center;
).h-flex-justify-end
(setsjustify-content: flex-end;
).h-flex-justify-space-between
(setsjustify-content: space-between;
).h-flex-justify-start
(setsjustify-content: flex-start;
).h-flex-grow
(setsflex-grow: 1;
)
Position
.h-clear
(setsclear: both;
).h-clear-left
(setsclear: left;
).h-clear-right
(setsclear: right;
).h-left
(setsfloat: left;
).h-right
(setsfloat: right;
)
Margin
.h-margin-0
(setsmargin: 0;
).h-margin-top-0
(setsmargin-top: 0;
).h-margin-right-0
(setsmargin-right: 0;
).h-margin-bottom-0
(setsmargin-bottom: 0;
).h-margin-left-0
(setsmargin-left: 0;
).h-margin-top
(setsmargin-top: 1rem;
).h-margin-right
(setsmargin-right: 1rem;
).h-margin-bottom
(setsmargin-bottom: 1rem;
).h-margin-left
(setsmargin-left: 1rem;
)
Padding
.h-padding-0
(setspadding: 0;
).h-padding-top-0
(setspadding-top: 0;
).h-padding-right-0
(setspadding-right: 0;
).h-padding-bottom-0
(setspadding-bottom: 0;
).h-padding-left-0
(setspadding-left: 0;
).h-padding-top
(setspadding-top: 1rem;
).h-padding-right
(setspadding-right: 1rem;
).h-padding-bottom
(setspadding-bottom: 1rem;
).h-padding-left
(setsmargin-left: 1rem;
)
Size
.h-full-height
(setsmin-height: 100vh;
).h-full-width
(setswidth: 100%;
).h-full
(setsmin-height: 100vh;
)
Text Alignment
.h-text-center
(setstext-align: center;
).h-text-left
(setstext-align: left;
).h-text-right
(setstext-align: right;
)
Customize & Extend
Designed to be both customizable and extensible.
Hydrogen is broken up into a set of responsive modules, adopting SMACSS as a convention for writing our CSS. For those who are new to SMACSS, you should give it a quick read, especially the section on module rules.
One of the conventions in Hydrogen is for every module to have a standard class name for common rules across a module, and then have additional class names for specific presentational rules for a specific sub-module. All classes start with a h-
prefix to prevent collisions.
Customize
To customize simply clone the source from GitHub, navigate to the project route & run npm install
and modify the contents of the _variables.less
and/or components/_variables.less
file(s). Once finished, run the build process by navigating to the project root and running npm start
.
Components
Common elements to help meet your deadlines.
Alerts
<div class="h-alert">I'm a test alert!</div>
<!-- With a close button -->
<div class="h-alert">
I'm a test alert with a close!
<span class="h-alert-close">×</span>
</div>
Badges
Badge 1 Badge 2
<span class="h-badge">Badge 1</span>
<span class="h-badge h-badge-fill">Badge 2</span>
Breadcrumbs
<div class="h-breadcrumbs">
<a href="#" class="h-breadcrumbs-item">Home</a>
<span class="h-breadcrumbs-spacer">/</span>
<a href="#" class="h-breadcrumbs-item">Stories</a>
<span class="h-breadcrumbs-spacer">/</span>
<span class="h-breadcrumbs-item">A Great Tale</span>
</div>
Button Groups
<div class="h-btn-group">
<button class="h-btn">Button 1</button>
<button class="h-btn">Button 2</button>
<button class="h-btn">Button 3</button>
<button class="h-btn">Button 4</button>
</div>
<div class="h-btn-group">
<button class="h-btn h-btn-fill">Button 1</button>
<button class="h-btn h-btn-fill">Button 2</button>
<button class="h-btn h-btn-fill">Button 3</button>
<button class="h-btn h-btn-fill">Button 4</button>
</div>
Cards
<div class="h-card h-text-center">
<div class="h-card-header">
Header
</div>
<div class="h-card-body">
I'm a test card!
</div>
<div class="h-card-footer">
Footer
</div>
</div>
Input Groups
<form action="" class="h-form h-form-stack">
<label>Website</label>
<div class="h-input-group h-margin-bottom">
<span class="h-input-group-addon">http://</span>
<input class="h-input-group-field" type="text" />
</div>
<label>Handle</label>
<div class="h-input-group h-margin-bottom">
<span class="h-input-group-addon">@</span>
<input class="h-input-group-field" type="text" />
</div>
<label>Email</label>
<div class="h-input-group h-margin-bottom">
<input class="h-input-group-field" type="text" />
<span class="h-input-group-addon">.com</span>
</div>
<label>Income</label>
<div class="h-input-group h-margin-bottom">
<span class="h-input-group-addon">USD$</span>
<input class="h-input-group-field" type="text" />
<span class="h-input-group-addon">.00</span>
</div>
<label>Ordered</label>
<div class="h-input-group h-margin-bottom">
<button class="h-input-group-addon">Up</button>
<button class="h-input-group-addon">Down</button>
<input class="h-input-group-field h-flex-grow" type="text" />
<button class="h-input-group-addon">Delete</button>
</div>
<label>Two Inputs</label>
<div class="h-input-group h-margin-bottom">
<input class="h-input-group-field" type="text" placeholder="Title" />
<input class="h-input-group-field h-flex-grow" type="text" placeholder="Name" />
</div>
<label>Three Inputs</label>
<div class="h-input-group h-margin-bottom">
<input class="h-input-group-field" type="text" placeholder="Title" />
<input class="h-input-group-field h-flex-grow" type="text" placeholder="Name" />
<input class="h-input-group-field" type="text" placeholder="Email" />
</div>
<label>Two Inputs Stack</label>
<div class="h-input-group h-input-group-stack">
<input class="h-input-group-field" type="text" placeholder="Title" />
<input class="h-input-group-field" type="text" placeholder="Name" />
</div>
<label>Editor</label>
<div class="h-input-group h-input-group-stack">
<input class="h-input-group-field" type="text" placeholder="Title" />
<textarea class="h-input-group-field" type="text" placeholder="Text"></textarea>
</div>
</form>
Pills
<button class="h-btn">
Button w/ Pill
<span class="h-pill h-right h-margin-left">3</span>
</button>
<button class="h-btn h-btn-fill">
Button w/ Pill
<span class="h-pill h-pill-inverted h-right h-margin-left">233</span>
</button>
<span class="h-badge">
Badge w/ Pill
<span class="h-pill h-right h-margin-left">1</span>
</span>
<span class="h-badge h-badge-fill">
Badge w/ Pill
<span class="h-pill h-pill-inverted h-right h-margin-left">122</span>
</span>
Titles
Title Subtitle
<h1 class="h-title">
Title
<span class="h-subtitle">Subtitle</span>
</h1>