All Projects → jforaker → React Accordion With Header

jforaker / React Accordion With Header

React accordion component with flexbox header

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Accordion With Header

React Flex Ready
A Flexbox grid ready, easy to implement and customize
Stars: ✭ 23 (+64.29%)
Mutual labels:  component, flexbox
Feather Flex
Ultralight flexbox based grid system.
Stars: ✭ 11 (-21.43%)
Mutual labels:  flexbox
Html
HTML helper library
Stars: ✭ 8 (-42.86%)
Mutual labels:  component
Aframe Persist Component
Persisting Aframe attribute data using localStorage
Stars: ✭ 10 (-28.57%)
Mutual labels:  component
Ui Box
Blazing Fast React UI Primitive
Stars: ✭ 847 (+5950%)
Mutual labels:  component
Dugong
Minimal State Store Manager for React Apps using RxJS
Stars: ✭ 10 (-28.57%)
Mutual labels:  component
Vue Step Progress
A simple Vue component that displays a Progress Bar with labels for each step
Stars: ✭ 26 (+85.71%)
Mutual labels:  component
Egjs
Javascript components group that brings easiest and fastest way to build a web application in your way.
Stars: ✭ 871 (+6121.43%)
Mutual labels:  component
Fish Ui
A Vue.js 2.0 UI Toolkit for Web
Stars: ✭ 861 (+6050%)
Mutual labels:  component
Repng
React component to PNG converter
Stars: ✭ 856 (+6014.29%)
Mutual labels:  component
Process
The Process component executes commands in sub-processes.
Stars: ✭ 6,942 (+49485.71%)
Mutual labels:  component
React Planner
✏️ A React Component for plans design. Draw a 2D floorplan and navigate it in 3D mode.
Stars: ✭ 846 (+5942.86%)
Mutual labels:  component
Mvvmhabitcomponent
👕基于MVVMHabit框架,结合阿里ARouter打造的一套Android MVVM组件化开发方案
Stars: ✭ 857 (+6021.43%)
Mutual labels:  component
Hedron
A no-frills flexbox grid system for React, powered by styled-components.
Stars: ✭ 847 (+5950%)
Mutual labels:  flexbox
Awloader
AWLoader is a UI Component that allows you to integrate loader that fits your needs within your app.
Stars: ✭ 11 (-21.43%)
Mutual labels:  component
Vuep
🎡 A component for rendering Vue components with live editor and preview.
Stars: ✭ 840 (+5900%)
Mutual labels:  component
Css Selector
The CssSelector component converts CSS selectors to XPath expressions.
Stars: ✭ 6,928 (+49385.71%)
Mutual labels:  component
React Input Tags
React component for tagging inputs.
Stars: ✭ 10 (-28.57%)
Mutual labels:  component
Routing
The Routing component maps an HTTP request to a set of configuration variables.
Stars: ✭ 7,080 (+50471.43%)
Mutual labels:  component
Polyfill Xml
This polyfill is deprecated. Use the symfony/polyfill-php72 package instead.
Stars: ✭ 11 (-21.43%)
Mutual labels:  component

react-accordion-with-header

React accordion component with customizable flexbox header

NPM

"You've got 5 seconds... and 3 are up." - Steven Seagal

Check out the demo NOW

Install via NPM:

npm install react-accordion-with-header

Import the modules:

import {
  AccordionWithHeader,
  AccordionNode,
  AccordionHeader,
  AccordionPanel
} from 'react-accordion-with-header';

Items can be passed in to <AccordionHeader /> and <AccordionPanel />:

  • as children (preferred)
  • as a component passed into the template prop (deprecated)

The elements passed in to <AccordionHeader /> can be horizontally justified and vertically aligned via their respective props 🎉 💥 🍻

  • horizontalAlignment
  • verticalAlignment

Pass in a component as a child to AccordionHeader and AccordionPanel:

(or plain html of course)

// note: due to the warning "Stateless function components cannot be given refs. Attempts to access this ref will fail."
// the components passed into <AccordionPanel> must be class components
// this allows to measure the height of the element via refs
class BodyTpl extends React.Component {
  render() {
    return <div>Look at this {this.props.item}</div>;
  }
}

class MyAccordion extends React.Component {
  render() {
    return (
      <AccordionWithHeader>
        {[1, 2, 3, 4].map((item, i) => {
          return (
            <AccordionNode key={i}>
              <AccordionHeader
                horizontalAlignment="centerSpaceAround"
                verticalAlignment="center"
              >
                <div>This is the header</div>
                <div>It has flexbox layout</div>
              </AccordionHeader>
              <AccordionPanel>
                <BodyTpl item={item} />
              </AccordionPanel>
            </AccordionNode>
          );
        })}
      </AccordionWithHeader>
    );
  }
}


actionCallback


  actionCallback = (panels, state) => {
    // fires any time headers are clicked and panels change state
    // receives array of panels: [{ panel: 3, open: true }, { panel: 6, open: true }]
    // and the AccordionWithHeader state
    console.log('panels, state', panels, state);
  }

  render() {
    return (
      <AccordionWithHeader actionCallback={this.actionCallback}>
        // ... stuff
      </AccordionWithHeader>
    );
  }

Props

(all components accept a className and style prop per usual convention)

<AccordionWithHeader />

Property Type Description Default
firstOpen Boolean Determines if the first panel should be expanded on init false
active Array Determines which panels are open (on componentDidMount or to control externally) []
multipleOkay Boolean True allows multiple panels to be expanded at the same time. False allows only one panel to be expanded at any time. false
actionCallback Function Callback function fired when a header is clicked and panel is opened or closed. Returns an array representing panels and the AccordionWithHeader state none
style Object style object none
className String CSS classname none

<AccordionNode />

Property Type Description Default
style Object style object none
className String Custom classname applied to root item div none

<AccordionHeader />

Property Type Description Default
title String For simple headers, a title will render an <h1> and disallow child elements none
titleColor String some valid CSS color or rgb or hex black
horizontalAlignment String One of: 'centerSpaceBetween', 'spaceBetween', 'centerSpaceAround', 'spaceAround', 'spaceEvenly', 'center', 'left', 'right'. Maps to corresponding flex-box CSS property centerSpaceAround
verticalAlignment String One of: 'top', 'center', 'bottom' center
style Object style object none
className String CSS classname none
template Element Component to be rendered as a template none

<AccordionPanel />

Property Type Description Default
template Element Component to be rendered as a template none
speed Number Speed in milliseconds to apply to CSS transition of open/close effect 250
style Object style object none
className String CSS classname none

What about styling?

You can styles to any component with a style prop or className prop

For example: <AccordionHeader style={{border: '1px solid'}}>

Or: <AccordionHeader className="myCssClass">


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].