Skip to content

Commit

Permalink
Merge pull request #99 from tamasnet/master
Browse files Browse the repository at this point in the history
Added support for centered horizontal tabs.
  • Loading branch information
yuriy-fix committed Jun 20, 2018
2 parents d7cda07 + 7e30cff commit ef1eb08
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions demo/tabs-basic-demos.html
Expand Up @@ -28,6 +28,17 @@ <h3>Vertical tabs</h3>
</template>
</vaadin-demo-snippet>

<h3>Centered horizontal tabs</h3>
<vaadin-demo-snippet id='tabs-basic-demos-centered-horizontal-tabs'>
<template preserve-content>
<vaadin-tabs centered>
<vaadin-tab>Tab one</vaadin-tab>
<vaadin-tab>Tab two</vaadin-tab>
<vaadin-tab>Tab three</vaadin-tab>
</vaadin-tabs>
</template>
</vaadin-demo-snippet>

<h3>Scrollable horizontal tabs</h3>
<vaadin-demo-snippet id='tabs-basic-demos-scrollable-horizontal-tabs'>
<template preserve-content>
Expand Down
13 changes: 13 additions & 0 deletions src/vaadin-tabs.html
Expand Up @@ -36,6 +36,10 @@
-ms-overflow-style: none;
}

:host([orientation="horizontal"][centered]) [part="tabs"] {
justify-content: center;
}

/* This seems more future-proof than `overflow: -moz-scrollbars-none` which is marked obsolete
and is no longer guaranteed to work:
https://developer.mozilla.org/en-US/docs/Web/CSS/overflow#Mozilla_Extensions */
Expand Down Expand Up @@ -121,6 +125,7 @@
* Attribute | Description | Part name
* -----------|-------------|------------
* `orientation` | Tabs disposition, valid values are `horizontal` and `vertical`. | :host
* `centered` | Center tabs horizontally. Ignored for vertical tabs, incompatible with scrolling. | :host
* `overflow` | It's set to `start`, `end`, none or both. | :host
*
* See [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin/wiki)
Expand Down Expand Up @@ -155,6 +160,14 @@
type: String
},

/**
* Center tabs horizontally. Ignored for vertical tabs, incompatible with scrolling.
*/
centered: {
value: false,
type: Boolean
},

/**
* The index of the selected tab.
*/
Expand Down

0 comments on commit ef1eb08

Please sign in to comment.