0.1.0-hack • Published 4 years ago

@paprika/hf-collapsible v0.1.0-hack

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

@paprika/collapsible

Description

Collapsible component, allows the user to expand and collapse some enclosed content.

Installation

yarn add @paprika/collapsible

or with npm:

npm install @paprika/collapsible

Props

Collapsible

PropTyperequireddefaultDescription
a11yTextstringfalsenullDescriptive a11y text for assistive technologies. By default, text from children node will be used.
childrennodefalsenullBody content of the collapsible.
iconAlign "left", "right"false"left"Set's icon alignment left or right.
iconCollapsenodefalseSets RightArrowIcon if true.
iconExpandnodefalseSets DownArrowIcon if true.
isCollapsedboolfalsetrueState of the collapsible.
isDisabledboolfalsefalseIf the collapsible is disabled.
hasOnlyIconToggleboolfalsefalse
labelnodetrue-Sets the label that will display in the collapsible
onClickfuncfalse() => {}Callback to be executed when the button is clicked or activated by keyboard.
triggerAriaDescribedbystringfalsenullaria-describedby on the trigger element.

Usage

import Collapsible from "@paprika/collapsible";

const [isCollapsed, setIsCollapsed] = React.useState(false);

const yourComponent = () => {
  return (
    <Collapsible
      a11yText="collapsible section"
      isCollapsed={isCollapsed}
      isDisabled={false}
      label="Click me to show/hide the content"
      iconAlign="left"
      onClick={() => setIsCollapsed(!isCollapsed)}
    >
      <p>
        <strong>Content</strong> – children of the &lt;Collapsible&gt; is hidden while the collapsible is collapsed, and
        visible with it is expanded.
      </p>
    </Collapsible>
  );
};

export default yourComponent;

Links