Installations
npm install @teste-ui/accordion
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
14.18.0
NPM Version
6.14.15
Releases
Unable to fetch releases
Download Statistics
Total Downloads
277
Last Day
1
Last Week
4
Last Month
8
Last Year
80
Bundle Size
30.94 kB
Minified
10.72 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.0.6
Package Id
@teste-ui/accordion@2.0.6
Unpacked Size
102.91 kB
Size
16.81 kB
File Count
14
NPM Version
6.14.15
Node Version
14.18.0
Total Downloads
Cumulative downloads
Total Downloads
277
Last day
0%
1
Compared to previous day
Last week
300%
4
Compared to previous week
Last month
300%
8
Compared to previous month
Last year
12.7%
80
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
6
Peer Dependencies
3
Dev Dependencies
3
@teste-ui/accordion
An accordion is a vertically stacked set of interactive headings that each contain a title or content snippet representing a section of content.
The headings function as controls that enable users to reveal or hide their associated sections of content.
Installation
1yarn add @teste-ui/accordion 2 3# or 4 5npm i @teste-ui/accordion
Import Components
1import { 2 Accordion, 3 AccordionItem, 4 AccordionButton, 5 AccordionPanel, 6} from "@teste-ui/accordion"
Component:
Accordion
: manages the global state of all opened accordion items via context.AccordionItem
: manages the state for a single accordion item.AccordionButton
: the trigger to open/close an accordion item.AccordionPanel
: the main content area for the accordion item.
Usage
By default, only one accordion can be visible at a time, and it can't be toggled.
Note 🚨: Each accordion button must be wrapped in a heading tag, that is appropriate for the information architecture of the page.
1<Accordion> 2 <AccordionItem> 3 <h2> 4 <AccordionButton>Section 1 title</AccordionButton> 5 </h2> 6 <AccordionPanel>Panel 1</AccordionPanel> 7 </AccordionItem> 8 9 <AccordionItem> 10 <h2> 11 <AccordionButton>Section 2 title</AccordionButton> 12 </h2> 13 <AccordionPanel>Panel 2</AccordionPanel> 14 </AccordionItem> 15</Accordion>
To make each accordion toggle (expand/collapse) on click, pass the allowToggle
prop.
1<Accordion allowToggle> 2 <AccordionItem> 3 <AccordionButton> 4 <chakra.div flex="1" textAlign="left"> 5 Section 1 title 6 </chakra.div> 7 <AccordionIcon /> 8 </AccordionButton> 9 <AccordionPanel pb={4}>Panel 1</AccordionPanel> 10 </AccordionItem> 11 12 <AccordionItem> 13 <AccordionButton> 14 <chakra.div flex="1" textAlign="left"> 15 Section 2 title 16 </chakra.div> 17 <AccordionIcon /> 18 </AccordionButton> 19 <AccordionPanel pb={4}>Panel 2</AccordionPanel> 20 </AccordionItem> 21</Accordion>
To allow multiple accordions to be visible at a time, pass the allowMultiple
prop.
1<Accordion allowMultiple> 2 <AccordionItem> 3 <AccordionButton> 4 <chakra.div flex="1" textAlign="left"> 5 Section 1 title 6 </chakra.div> 7 <AccordionIcon /> 8 </AccordionButton> 9 <AccordionPanel pb={4}>Panel 1</AccordionPanel> 10 </AccordionItem> 11 12 <AccordionItem> 13 <AccordionButton> 14 <chakra.div flex="1" textAlign="left"> 15 Section 2 title 16 </chakra.div> 17 <AccordionIcon /> 18 </AccordionButton> 19 <AccordionPanel pb={4}>Panel 2</AccordionPanel> 20 </AccordionItem> 21</Accordion>
References:
https://www.w3.org/TR/wai-aria-practices/examples/accordion/accordion.html https://inclusive-components.design/collapsible-sections/ https://github.com/stereobooster/react-accessible-accordion https://jqueryui.com/accordion/
No vulnerabilities found.
No security vulnerabilities found.