--- layout: default title: Components · Ratchet ---
{% include masthead.html %}

Components

Design patterns that serve as basic building blocks.

{% include ad.html %}
{% include toolbar.html %}

Title

Title bar

Title bars are full width and docked to the top of the viewport.

Title

{% highlight html %}

Title

{% endhighlight %}

Title bar with buttons

Buttons in a title bar are left or right aligned and should be used for actions. Use the .pull-right or .pull-left utility classes to float the buttons. Also, be sure to place any floated elements before the title.

Title

{% highlight html %}

Title

{% endhighlight %}

Title bar with icons

Icons can also be used for actions in toolbars. Again, be sure to use utility classes to float the icons into position.

Title

{% highlight html %}

Title

{% endhighlight %}

Title bar with link buttons and icons

Link buttons can be used in tool bars to remove the outline. Use these in conjuction with icons to recreate the nav feel from iOS7. Note the use of .btn-nav to bring the buttons a little bit closer to the edge of the viewport.

Title

{% highlight html %}

Title

{% endhighlight %}

Title bar with segmented control

Title bars can also house segmented controls. Feel free to add accompanying buttons too. The control will automatically layout itself out correctly.

{% highlight html %}
{% endhighlight %}

Tab bar (labels only)

If you don't want to use icons, that's okay too. The text will appear larger to use the additional space.

{% highlight html %} {% endhighlight %}

Note: Use push.js to actually change content.

Standard bars

Standard bars are basic fixed elements that can be positioned in four places. These can be used to house buttons, icons, or segmented controls (see following examples).

{% highlight html %}
{% endhighlight %}

Typography

Use headings and paragraphs to title and describe sections of your app. Apply or wrap elements with .content-padded to give the content space around the screen.

h1. Heading

h2. Heading

h3. Heading

h4. Heading

h5. Heading
h6. Heading

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.

{% highlight html %}

h1. Heading

h2. Heading

h3. Heading

h4. Heading

h5. Heading
h6. Heading

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.

{% endhighlight %}

Table views

Table views can be used for organizing data, showing collections of links, or a series of controls.

  • Item 1
  • Item 2
  • Divider
  • Item 3
{% highlight html %}
  • Item 1
  • Item 2
  • Divider
  • Item 3
{% endhighlight %}

Table view with chevrons

Chevrons should be used to indicate that the item is linked. Just apply the classes .navigate-right or .navigate-left to use a chevron.

{% highlight html %} {% endhighlight %}

Note: Table views with the Android theme don't have chevrons to comply with Android Design guidelines. More information can be found here.

Table view with badges

Badges are a great way of showing data.

  • Item 1 4
  • Item 2 1
  • Item 3 5
{% highlight html %}
  • Item 1 4
  • Item 2 1
  • Item 3 5
{% endhighlight %}

Table view with media (images)

Showing media inside table views is easy. This component to perfect for images and text.

{% highlight html %} {% endhighlight %}

Table view with buttons

  • Item 1
  • Item 2
  • Item 3
  • Item 4
{% highlight html %}
  • Item 1
  • Item 2
  • Item 3
  • Item 4
{% endhighlight %}

Table view with toggles

  • Item 1
  • Item 2
  • Item 3
{% highlight html %}
  • Item 1
  • Item 2
  • Item 3
{% endhighlight %}

Carded table views

Use .card to wrap any content in a padded element.

  • Item 1
  • Item 2
  • Divider
  • Item 3
  • Item 4
{% highlight html %}
  • Item 1
  • Item 2
  • Divider
  • Item 3
  • Item 4
{% endhighlight %}

Buttons

Buttons come in many flavors and should be used for user actions.

{% highlight html %} {% endhighlight %}

Buttons with icons

Ratchicons work inside buttons too.

{% highlight html %} {% endhighlight %}

Buttons with badges

{% highlight html %} {% endhighlight %}

Block buttons

{% highlight html %} {% endhighlight %}

Segmented control

Content sections that are to be swapped in and out by the controller should all be siblings and have the class .control-content. Then, just give each content section an id and point the link in the segmented control to that id.

{% highlight html %}
Item 1 Item 2 Item 3
{% endhighlight %}

Badges

Badges come in four flavors and should be used to indicate "how many" of something there are. Adding the a class of .badge-inverted will remove the badges background color.

1 2 3 4 1 2 3 4
{% highlight html %} 1 2 3 4 1 2 3 4 {% endhighlight %}

Forms

{% highlight html %}
{% endhighlight %}

Form with input group

{% highlight html %}
{% endhighlight %}

Form with input group and labels

{% highlight html %}
{% endhighlight %}

Toggles

Toggles can be used by sliding or tapping the control.

{% highlight html %}
{% endhighlight %}

Toggles.js binds an event to the document that returns a detail object and can be used to fire a callback.

{% highlight js %} // Only needed if you want to fire a callback document .querySelector('#myToggle') .addEventListener('toggle', myFunction) {% endhighlight %}

Popovers

{% highlight html %}

Popover title

  • Item1
  • Item2
  • Item3
  • Item4
  • Item5
  • Item6
  • Item7
  • Item8
{% endhighlight %}

Popovers are designed to only fire from title bars. Set the value of the title href to the id of a popover, like so:

{% highlight html %}

Tap title

{% endhighlight %}

Modals

Open modal
{% highlight html %} Open modal {% endhighlight %}

Modals are designed to only fire from links. Set the value of the toggle links href to the id of a modal.

Sliders

Can be used with any number of slides with any type of content.

Mountain and sky Slide me
Giant mecha
Big Ben
{% highlight html %}
Slide me
{% endhighlight %}

Sliders.js binds an event to the document that returns a detail object and can be used to fire a callback.

{% highlight js %} // Only needed if you want to fire a callback document .querySelector('#mySlider') .addEventListener('slide', myFunction) {% endhighlight %}

Push

Push.js is the engine that connects Ratchet pages together with AJAX and the history api. Push.js is listening to all clicks on a page, so just make sure it's included and link something in your Ratchet project up.

{% highlight html %} Two {% endhighlight %}

This will use push to replace everything in the .content div with the .content of two.html. Also, it will either update or remove .bar-nav and .bar-tab according to their presences in two.html.

Now that pages are being loaded through push, it's easy to specify transitions for animations between pages. There are three different transitions to chose from: fade, slide-in, or slide-out.

{% highlight html %} Two {% endhighlight %}

A working version of push:

{% highlight html %}

Push

{% endhighlight %}

Have a link you don't want to intercepted by push? Try this:

{% highlight html %} Google {% endhighlight %}

Push.js binds an event to the document that returns a detail object and can be used to fire a callback.

{% highlight js %} // Only needed if you want to fire a callback window.addEventListener('push', myFunction); {% endhighlight %}

Push.js can be triggered manually by using the PUSH(options) function. When passing options, url is required, container, transition and timeout are optional. As of version 2.1.0 Ratchet has its own namespace and can also be called with RATCHET.push(options).

{% highlight js %} PUSH({url: "/signin"}); RATCHET.push({url: "/signin"}); {% endhighlight %}

Ratchicons

Use Ratchicons in your application to help inform interactions.

{% for iconClassName in site.data.ratchicons %} {% endfor %}
{% highlight html %}
{% for iconClassName in site.data.ratchicons %} {% endfor %}
{% endhighlight %}
{% include footer.html %}