2.1.0 • Published 4 years ago

dile-tabs v2.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

\

Web Component to implement a tabs interface. Based on LitElement

Go to DEMOS page

Installation

npm i dile-tabs

Usage

<dile-tabs> is a component you may use to select one of several posible values. It shows to the user creating a tabs interface.

To use the component you need include (or import) the component script, and then use a markup based on two tags. First of them is <dile-tabs>, which is the entire set of tabs. The second component is <dile-tab> (in singular), which is one of the tabs of the interface.

<script type="module">
  import 'dile-tabs/dile-tabs.js';
</script>

<dile-tabs selected="2">
    <dile-tab>One</dile-tab>
    <dile-tab>Two</dile-tab>
    <dile-tab>Three</dile-tab>
    <dile-tab>Four</dile-tab>
  </dile-tabs>

Properties

The component has the properties bellow:

selected:

This property sets the currently selected tab of the interface. By default the selected value need to be an integer, specifying th index of the selected tab (starting at 0 for the first tab, 1 for the second...).

attrForSelected:

This property tells the <dile-tabs> component which attribute need to match the selected property to set the active tab. By default atrrForSelected is undefined. In that case the selected property should be an integer and match to the index of the tab. If you set atrrForSelected with a value, then the selected property will be matched with the value of the attribute named in attrForSelected.

The next example show how to use the attrForSelected property

<dile-tabs selected="posts" attrForSelected="name">
  <dile-tab name="users">Users</dile-tab>
  <dile-tab name="posts">Posts</dile-tab>
  <dile-tab name="articles">Articles</dile-tab>
  <dile-tab name="faq">FAQ</dile-tab>
  <dile-tab name="contact">Contact</dile-tab>
</dile-tabs>

Events

dile-tabs-selected-changed:

When selected property changes by a user interaction inside the <dile-tabs> component, it dispatch the dile-tabs-selected-changed custom event. You will recive the new selected value in the detail event object property.

CSS custom properties

You can customize the tabs using the CSS custom properties bellow.

Custom propertyDescriptionDefault
--dile-tab-text-colorThe tab text color#666
--dile-tab-background-colorThe tab background colorTransparent
--dile-tab-selected-text-colorThe tab text color#fff
--dile-tab-selected-background-colorThe tab background color#039be5;
--dile-label-paddingContent padding of the tab8px 12px 6px 12px
--dile-tab-selected-line-heightDefines selected tab line height5px
--dile-tab-selected-line-colorDefines selected tab line color#0070c0
--dile-tab-border-radiusTab top-left & top-right border radius4px
--dile-tab-borderUnselected tab bordernone
--dile-tab-selected-borderSelected tab bordernone
--dile-tab-font-weightTab font weightnormal
--dile-tab-text-transformTab text transformuppercase
2.1.0

4 years ago

2.0.7

4 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago