0.1.0-hack • Published 4 years ago

@paprika/hf-tabs v0.1.0-hack

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

@paprika/tabs

Description

Tabs component displays tabs with panels associated with each tab

Installation

yarn add @paprika/tabs

or with npm:

npm install @paprika/tabs

Props

Tabs

PropTyperequireddefaultDescription
a11yTextstringfalsenullDescription of the purpose of the tabs for assistive technology.
childrennodetrue-Expects Tabs.List (mandatory) and Tabs.Panels (optional).
defaultIndexnumberfalseundefinedSets what tabindex is active by default (uncontrolled component). Use null for no active tab.
hasInsetFocusStyleboolfalsefalseIf the visual focus ring for the tabs should be displayed with an inset style.
hasTruncationboolfalsefalseTab labels will be truncated when they run out of space instead of breaking to multiple lines (ignored when isVertical is false).
indexnumberfalseundefinedSets what tabindex is active (controlled component). Use null for no active tab.
isDisabledboolfalsefalseIf the tabs are all disabled.
isVerticalboolfalsefalseIf the tabs are stacked vertically.
kind Tabs.types.kind.PRIMARY, Tabs.types.kind.SECONDARYfalseTabs.types.kind.PRIMARYThe visual theme of the tabs list.
onClickTabfuncfalsenullUse this prop when you want to use Tabs as a controlled component (also you must use 'index' prop). When the user clicks on a tab, this gets fired (the tab index is passed to it).
size Tabs.types.size.MEDIUM, Tabs.types.size.LARGEfalseTabs.types.size.MEDIUMSize of the tab label text.
tabHeightnumber,stringfalse48Height of the tabs (ignored when isVertical is true). A number value will be interpreted as height in pixels.

Tabs.List

PropTyperequireddefaultDescription
childrennodetrue-List of Tabs.Tab elements.

Tabs.Panel

PropTyperequireddefaultDescription
childrennodefalsenull
isSelectedboolfalsefalseControls if the option is selected or not
shouldUnmountboolfalsetrueShould unmount or not when isSelected is false

Tabs.Panels

PropTyperequireddefaultDescription
childrennodetrue-List of Tabs.Panel elements.

Tabs.Tab

PropTyperequireddefaultDescription
a11yTextstringfalsenullDescriptive text for assistive technologies. By default text of the children will be used.
childrennodefalsenullLabel for the tab
hasFocusboolfalsefalseInternal only: if tab has focus
hrefstringfalsenullSets a url the tab goes to
isDisabledboolfalsefalseIf the tab is disabled
isSelectedboolfalsefalseInternal only: if tab is selected
onClickfuncfalse() => {}Internal only: callback onClick
onKeyDownArrowsfuncfalse() => {}Internal only: callback onKeyDownArrow

Usage

import Tabs from "@paprika/tabs";

<Tabs>
  <Tabs.List>
    <Tabs.Tab>Hello</Tabs.Tab>
    <Tabs.Tab isDisabled>World</Tabs.Tab>
    <Tabs.Tab>ABC</Tabs.Tab>
    <Tabs.Tab isDisabled>Disabled Tab</Tabs.Tab>
  </Tabs.List>
  <Tabs.Panels>
    <Tabs.Panel>Hello Tab</Tabs.Panel>
    <Tabs.Panel>Disabled tab 2</Tabs.Panel>
    <Tabs.Panel>ABC Tab</Tabs.Panel>
    <Tabs.Panel>Disabled tab 4</Tabs.Panel>
  </Tabs.Panels>
</Tabs>;

Links