YUI App Theme

Tonight I pushed a new project to GitHub called yui-app-theme. It’s a generic, skinnable layout designed for web applications — particularly admin areas — built using YUI Grids.

In other words, it’s a starting point.

Usually when doing freelance work for clients, unless you’re building on top of an existing CMS like WordPress or MiaCMS, you’ll have to create an admin area for the client to login and manage their site. Or maybe you’re building a bug tracker or some other web application. Whatever the situation, yui-app-theme provides a solid foundation to start your work.

It offers a tabbed layout with many of the common UI elements that web apps need. Content blocks, tabbed modules, one and two-column forms, error messages, etc. But most importantly it’s built using YUI Grids so it’s semantically structured, cross-browser, and easy to extend. You can radically alter the layout with just a few quick changes. Try clicking through the layout options on the demo page.

I’ve done my best to keep things logical and easy to use. Here’s a quick example of how to use and extend the built-in content blocks.

A basic content block, or module, is created with the following markup

1

2

3

4

5

6

7

8

9

&lt;div class="block"&gt;

&lt;div class="hd"&gt;

&lt;h2&gt;Your Header Content&lt;/h2&gt;

&lt;/div&gt;

&lt;div class="bd"&gt;

&lt;p&gt;Your body content goes here.&lt;/p&gt;

&lt;/div&gt;

&lt;/div&gt;

You have a containing div with a class name of block surrounding two inner divs, which make up the head and body content of the block. In the browser you’ll see

Content blocks resize to fit their surroundings. That means you can take the same markup used for a body content block and move it into a sidebar — the block will automatically shrink to fit the smaller space.

We can also extend the block to have a tabbed appearance. To do this, we just need to add an extra tabs class and define our tabs using a <ul>.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

&lt;div class="block tabs"&gt;

&lt;div class="hd"&gt;

&lt;ul&gt;

&lt;li class="active"&gt;&lt;ahref="#"&gt;Tab1&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;ahref="#"&gt;Tab2&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;ahref="#"&gt;Tab3&lt;/a&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="clear"&gt;&lt;/div&gt;

&lt;/div&gt;

&lt;div class="bd"&gt;

&lt;p&gt;Your body content goes here.&lt;/p&gt;

&lt;/div&gt;

&lt;/div&gt;

Easy.

However, you’ll notice than by using an unordered list to build our tabs, we had to remove the <h2> tag. In some situations we may want to keep that header around for SEO purposes — visible to search engines but hidden from users. yui-app-theme handles this situation automatically by hiding any <h2> and <h3> tags inside a content block’s header. (Technically, it applies an extreme negative left margin to move it outside the browser window.)

Let’s take this example one step further and change the appearance of the tabs by making them look separated. All we have to do is add a spaces class to the content block.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

&lt;div class="block tabs spaces"&gt;

&lt;div class="hd"&gt;

&lt;ul&gt;

&lt;li class="active"&gt;&lt;ahref="#"&gt;Tab1&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;ahref="#"&gt;Tab2&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;ahref="#"&gt;Tab3&lt;/a&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="clear"&gt;&lt;/div&gt;

&lt;/div&gt;

&lt;div class="bd"&gt;

&lt;p&gt;Your body content goes here.&lt;/p&gt;

&lt;/div&gt;

&lt;/div&gt;

And we get

It’s that simple. With the right CSS, minor HTML edits can create powerful changes when rendered.

If you explore the demo you’ll see that applies to the page layout as well. You can very quickly change the color scheme or page width. And even adjust the sidebar, move it to the opposite side, or switch the layout to a single column. It’s all possible because yui-app-theme, itself, is built on top of a solid foundation — YUI.

I’ve already started using this template in my own projects and found it incredibly helpful to have my application layout up and running so quickly. I hope you can benefit from it, too. And, please, feel free to fork yui-app-theme on GitHub and contribute your own improvements.