1.0.2 • Published 3 years ago

react-botw-tabs v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

react-botw-tabs

A tab sheet component styled like Zelda: Breath of the Wild menus.

NPM JavaScript Style Guide

Contents

Install

npm install --save react-botw-tabs

Peer Dependencies;

  • React v16 +

Usage

import React, { Component } from 'react'

import { BotwTabs } from 'react-botw-tabs'

class Example extends Component {
  render() {
    return (
      <BotwTabs
        defaultActiveId={"pencil"}
        tabs={[
          {
            id: "pencil",
            name: "Pencil",
            faicon: <i className="fa fa-pencil" />,
            content: (
              <div style={{ textAlign: "center" }}>
                <h3>This is the Pencil tab.</h3>
              </div>
            )
          },
          {
            id: "bomb",
            name: "Bomb",
            faicon: <i className="fa fa-bomb" />,
            content: (
              <div style={{ textAlign: "center" }}>
                <h3>This is the Bomb tab.</h3>
              </div>
            )
          }
        ]}
      />
    )
  }
}

Examples at https://darylbuckle.github.io/react-botw-tabs.

Example with other botw-menu components at https://darylbuckle.github.io/react-botw-menu-components.

Props

BotwTabs

PropertyTypeDefaultMandatoryDescription
tabsbotwTab[]trueThe tabs to display. This also includes the tab content.
activeIdstringfalseIf controlling the active tab, this is the id of the current active tab.
defaultActiveIdstringfalseIf uncontrolled, this is the id of the default active tab.
onChange(tab) => voidfalseA callback for when a new tab is selected.
classNamestringfalseAdditional css classes for the container.
styleReact.CSSPropertiesfalseAdditional styles for the container.
tabsheetClassNamestringfalseAdditional css classes for the tab content container.
tabsheetStyleReact.CSSPropertiesfalseAdditional styles for the tab content container.

botwTab class

PropertyTypeDefaultMandatoryDescription
idstringtrueUnique identifier for the tab.
namestringtrueThe name of the tab.
imgSrcstringfalseSrc of the image.
activeImgSrcstringfalseOverride the image source when active.
faiconanyfalseAlternative to ImgSrc. Allows JSX to be used for the image (e.g font awesome icons)
classNamestringfalseAdditional css classes for the tab.
styleReact.CSSPropertiesfalseAdditional styles for the tab.
contentAny JSXfalseThe actual content of the tab. This is rendered if the tab is selected. It's rendered underneath the tab sheet.

License

MIT © DarylBuckle 2020