0.0.5 • Published 5 years ago

@volvo-cars/accordion-component v0.0.5

Weekly downloads
5
License
UNLICENSED
Repository
github
Last release
5 years ago

Accordion

Basic usage

<Accordion label="Accordion example">
  <Block as="p">...text</Block>
</Accordion>

Usage with parent state

const MultipleControlledAccordions = () => {
  const [active, setActive] = useState(-1);

  return (
    <>
      {times(4).map((d, i) => (
        <Accordion
          label={`Accordion example ${i + 1}`}
          key={i}
          onChange={() => setActive(i)}
          isOpen={i === active}
        >
          <Content />
        </Accordion>
      ))}
    </>
  );
};

Props

PropsTypeDescriptionRequiredDefault
labelstringLabel✔︎null
childrenjsxChildren for the Accordion's expandable content section✔︎null
onChangefuncCallback fired when accordion open state is changednull
extendobjectExtend styles of accordionnull
extendContentobjectExtend styles of accordion contentnull