1.0.0-prerelease.7 • Published 6 years ago

@rhelements/rh-tabs v1.0.0-prerelease.7

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

RHElements Tabs Element

Usage

<rh-tabs>
  <rh-tab role="heading" slot="tab">Tab 1</rh-tab>
  <rh-tab-panel role="region" slot="panel">
    <h2>Content 1</h2>
    <p>Tab 1 panel content.</p>
  </rh-tab-panel>
  <rh-tab role="heading" slot="tab">Tab 2</rh-tab>
  <rh-tab-panel role="region" slot="panel">
    <h2>Content 2</h2>
    <p>Tab 2 panel content.</p>
  </rh-tab-panel>
</rh-tabs>

For each rh-tab, you are responsible for setting the role="heading"and slot="tab".

For each rh-tab-panel, you are responsible for setting role="region" and slot="panel".

Slots

Default slot in rh-tabs

Place the rh-tab and rh-tab-panel elements here.

Default slot in rh-tab

Add the text for your tab here.

Default slot in rh-tab-panel

Add the content for your tab panel here.

Attributes

vertical (observed)

Orients the tabs vertically on the left and pushes the content panes to the right.

<rh-tabs vertical>
  ...
</rh-tabs>

selected-index (observed)

Sets and reflects the currently selected tab index.

<rh-tabs selected-index="2">
  ...
</rh-tabs>

Events

rh-tabs:shown-tab

Fires when a new tab is selected. The event.detail.tab will be the tab that has been selected.

rh-tabs:hidden-tab

Fires when a selected tab is no longer the selected tab. The event.detail.tab will be the tab that is no longer selected.

Styling

Theme Var HookDescriptionDefault
--rh-theme--container-paddingTab padding and panel padding16px
--rh-theme--color--surface--borderLink color for default CTA$rh-color--surface--border
--rh-theme--ui--border-styleBorder style for selected tabsolid
--rh-theme--ui--border-widthBorder width for selected tab1px
--rh-theme--color--surface--lightestSelected tab background color$rh-color--surface--lightest
--rh-theme--color--surface--lightest--textDefault tab text color$rh-color--surface--lightest--text
--rh-theme--color--surface--lightest--linkTab hover and selected indicator color$rh-color--surface--lightest--link
--rh-theme--color--surface--lightest--link--focusFocused tab outline color$rh-color--surface--lightest--link--focus
--rh-tabs__indicator--DisplayTab indicator displayblock
--rh-tabs__indicator--HeightTab indicator height4px
--rh-tabs__indicator--WidthTab indicator width22px
--rh-tabs__tab--TextTransformTab text transformnone

Test

npm run test

Build

npm run build

Demo

From the RHElements root directory, run:

npm start

Code style

Tabs (and all RHElements) use Prettier to auto-format JS and JSON. The style rules get applied when you commit a change. If you choose to, you can integrate your editor with Prettier to have the style rules applied on every save.