@newfrontdoor/collapse
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

@newfrontdoor/collapse

<Collapse />

Usage

import {useRef} from 'react';
import {Collapse} from '@newfrontdoor/collapse';

const contentRef = useRef(null);

return (
  <Collapse.Manager contentRef={contentRef}>
    <Collapse.Toggle>
      <button type="button">Toggle Me</button>
    </Collapse.Toggle>
    <Collapse.Panel>
      Collapse Content
    </Collapse.Panel>
  </Collapse.Manager>
)

useCollapse()

Usage

import {useRef} from 'react';
import {useCollapse} from '@newfrontdoor/collapse';

const contentRef = useRef(null);
const {getToggleProps, getCollapseProps} = useCollapse({
  contentRef
});

return (
  <div>
    <button {...getToggleProps()} type="button">
      Toggle Me
    </button>
    <div {...getCollapseProps()}>
      <div ref={contentRef}>
        Collapse Content
      </div>
    </div>
  </div>
);

Readme

Keywords

none

Package Sidebar

Install

npm i @newfrontdoor/collapse

Weekly Downloads

1

Version

0.2.3

License

MIT

Unpacked Size

69.2 kB

Total Files

14

Last publish

Collaborators

  • barrythepenguin
  • readeral
  • deeksy
  • instagibb
  • bratalix
  • camdude