Tabs have arrived! BaseWeb now makes available the tabs block component which includes two robust mixins for creating and styling semantic tabs.
+ +Before I get into the solution we applied in BaseWeb, I want to explore the process of researching and developing this component. Tabs are a very common user interface control and have been around for a while. This is important because it means users have an expectation with how tabs function and look. So when developing a tabs system, we want to make sure we are as predictable as possible for users as well as being clear visually. So lets put together a checklist to clearly define how tabs should look and function before we code. + +1. **Tabs are used to switch between views within the same context.** It's important to note that tabs should only be used as a high level organizational control for content. +2. **Tabs appear horizontally above the panel they represent.** This may seem obvious, but keeping this pattern consistent leverages the already learned behavior of users. +3. **Only one tab should be active at a time.** This shouldn't be mistaken for content toggle controls like the accordion where multiple content panes can be active at once. +4. **Tab text is usually short and descriptive.** They should be easily scannable and there should be no confusion what content a user will see when a tab is clicked. +5. **Tabs should not be used as site navigation.** This is something I've seen before and it can cause confusion and inconsistency for a user. There's a clear distinction between a site's navigation and tab controls and this should be represented both functionally and visually. +6. **Tabs shouldn't contain content that needs to be compared.** Because only one tab panel should be active at a time, content between tabs shouldn't need to be compared or needed to be viewed together. If your content requires this sort of interaction, tabs are not the appropriate control. +7. **Active tabs should be super obvious and work even when only two tabs are present.** This deals more with the visuals of the tabs themselves, but it's helpful to know which tab is currently active, even when only two exist. We'll talk more about this when we go over tab styling. + +## Tackling the Markup + +A semantic tabs system contains two primary parts, the tab controls and the panels of content they toggle. We'll start with the tabs who's markup we can write similar to a set of navigation links: + +```html + +``` + +Next, we'll write a quick set of divs that represent our content panes which we'll control with the tabs navigation. + +```html +See the Pen BaseWeb Tabs - Vanilla by Sebastian Nitu (@sebnitu) on CodePen.
+ + +With this as our base, we can go any stylistic direction we'd like. [Mary Lou](https://tympanus.net/codrops/2014/09/02/tab-styles-inspiration/) wrote a great post on Codrops if you're looking for some inspiration. For our purposes, we want some very basic styles that can be easily adopted in most projects without much effort. Here are the two options that we came up with which can be modified to suit most situations. + +See the Pen BaseWeb Tabs - Fold Styles by Sebastian Nitu (@sebnitu) on CodePen.
+ + +See the Pen BaseWeb Tabs - Line Styles by Sebastian Nitu (@sebnitu) on CodePen.
+ + +## Conclusion + +That wraps up our tabs block component solution. We've managed to hit all our requirements we listed in the introduction. The next steps we took in BaseWeb involve creating a variable map for customization and some handy mixins that abstract our styles a bit. You can read more about that implementation over on the [documentations page](/docs/blocks/tabs/). + +### Further Reading + + diff --git a/docs/docs/blocks/notices.md b/docs/docs/blocks/notices.md index ca7b67d2..922de5bf 100644 --- a/docs/docs/blocks/notices.md +++ b/docs/docs/blocks/notices.md @@ -51,14 +51,6 @@ $('.dismissible > .close').on('click', function() {Tab Content 1
Tab Content 2
Tab Content 3
Tab Content 4
Tab Content 5
Tab Content 1
Tab Content 2
Tab Content 3
Tab Content 4
Tab Content 5
Tab Content 1
Tab Content 2
Tab Content 3
Tab Content 4
Tab Content 5
Variable | +Default | +
---|---|
$tabs('classes') |
+ true * |
+
$tabs('class-wrapper') |
+ 'tabs' |
+
$tabs('class-nav') |
+ 'tabs-nav' |
+
$tabs('class-content') |
+ 'tabs-content' |
+
$tabs('class-content-panel') |
+ 'tabs-panel' |
+
$tabs('margin') |
+ 2em 0 |
+
$tabs('padding-nav') |
+ 1em |
+
$tabs('padding-nav-inline') |
+ 1em 2em |
+
$tabs('padding-content') |
+ 1em 2em |
+
$tabs('background') |
+ #f5f5f5 |
+
$tabs('background-fade') |
+ #e6e6e6 |
+
$tabs('background-accent') |
+ $white |
+
$tabs('border') |
+ 1px solid #e6e6e6 |
+
$tabs('border-radius') |
+ $border-radius |
+
$tabs('color') |
+ $color |
+
$tabs('color-fade') |
+ $color-light |
+
$tabs('color-accent') |
+ $blue |
+
$tabs('transition') |
+ $transition |
+
Variable | +Type | +Default | +
---|---|---|
$options |
+ Map | +$tabs() |
+
Variable | +Type | +Default | +
---|---|---|
$options |
+ Map | +$tabs() |
+
$style |
+ String (fold, line) | +'fold' |
+
$class |
+ String | +'style-#{$style}' |
+