Accordion - 图1

Accordion React Component

Accordion React component represents Framework7’s Accordion component.

Accordion Components

There are following components included:

  • **Accordion** / **F7Accordion**
  • **AccordionItem** / **F7AccordionItem**
  • **AccordionToggle** / **F7AccordionToggle**
  • **AccordionContent** / **F7AccordionContent**

Accordion Properties

PropTypeDefaultDescription
<AccordionItem> properties
openedbooleanMakes accordion item opened

Accordion Events

EventDescription
<AccordionItem> events
accordionBeforeOpenEvent will be triggered right before accordion content starts its opening animation. event.detail.prevent contains function that will prevent accordion from opening when called
accordionOpenEvent will be triggered when accordion content starts its opening animation.
accordionOpenedEvent will be triggered after accordion content completes its opening animation.
accordionBeforeCloseEvent will be triggered right before accordion content starts its closing animation. event.detail.prevent contains function that will prevent accordion from closing when called
accordionCloseEvent will be triggered when accordion content starts its closing animation.
accordionClosedEvent will be triggered after accordion content completes its closing animation.

Accordion List

Accordion List is not a separate component, but just a particular case of using [<List>]($7b374ae2a08124d4.md), [<ListItem>]($0b7121fee8bea8f7.md) and <AccordionContent> components.

In this case accordion events will be fired on ListItem.

Examples

  1. export default () => (
  2. <Page>
  3. <Navbar title="Accordion"/>
  4. <BlockTitle>List View Accordion</BlockTitle>
  5. <List accordionList>
  6. <ListItem accordionItem title="Lorem Ipsum">
  7. <AccordionContent>
  8. <Block>
  9. <p>
  10. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean elementum id neque nec commodo. Sed vel justo at turpis laoreet pellentesque quis sed lorem. Integer semper arcu nibh, non mollis arcu tempor vel. Sed pharetra tortor vitae est rhoncus, vel congue dui sollicitudin. Donec eu arcu dignissim felis viverra blandit suscipit eget ipsum.
  11. </p>
  12. </Block>
  13. </AccordionContent>
  14. </ListItem>
  15. <ListItem accordionItem title="Nested List">
  16. <AccordionContent>
  17. <List>
  18. <ListItem title="Item 1"></ListItem>
  19. <ListItem title="Item 2"></ListItem>
  20. <ListItem title="Item 3"></ListItem>
  21. <ListItem title="Item 4"></ListItem>
  22. </List>
  23. </AccordionContent>
  24. </ListItem>
  25. <ListItem accordionItem title="Integer semper">
  26. <AccordionContent>
  27. <Block>
  28. <p>
  29. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean elementum id neque nec commodo. Sed vel justo at turpis laoreet pellentesque quis sed lorem. Integer semper arcu nibh, non mollis arcu tempor vel. Sed pharetra tortor vitae est rhoncus, vel congue dui sollicitudin. Donec eu arcu dignissim felis viverra blandit suscipit eget ipsum.
  30. </p>
  31. </Block>
  32. </AccordionContent>
  33. </ListItem>
  34. </List>
  35. <BlockTitle>Inset Accordion</BlockTitle>
  36. <List accordionList inset>
  37. <ListItem accordionItem title="Lorem Ipsum">
  38. <AccordionContent>
  39. <Block>
  40. <p>
  41. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean elementum id neque nec commodo. Sed vel justo at turpis laoreet pellentesque quis sed lorem. Integer semper arcu nibh, non mollis arcu tempor vel. Sed pharetra tortor vitae est rhoncus, vel congue dui sollicitudin. Donec eu arcu dignissim felis viverra blandit suscipit eget ipsum.
  42. </p>
  43. </Block>
  44. </AccordionContent>
  45. </ListItem>
  46. <ListItem accordionItem title="Nested List">
  47. <AccordionContent>
  48. <List>
  49. <ListItem title="Item 1"></ListItem>
  50. <ListItem title="Item 2"></ListItem>
  51. <ListItem title="Item 3"></ListItem>
  52. <ListItem title="Item 4"></ListItem>
  53. </List>
  54. </AccordionContent>
  55. </ListItem>
  56. <ListItem accordionItem title="Integer semper">
  57. <AccordionContent>
  58. <Block>
  59. <p>
  60. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean elementum id neque nec commodo. Sed vel justo at turpis laoreet pellentesque quis sed lorem. Integer semper arcu nibh, non mollis arcu tempor vel. Sed pharetra tortor vitae est rhoncus, vel congue dui sollicitudin. Donec eu arcu dignissim felis viverra blandit suscipit eget ipsum.
  61. </p>
  62. </Block>
  63. </AccordionContent>
  64. </ListItem>
  65. </List>
  66. <BlockTitle>Custom Collapsible</BlockTitle>
  67. <Block inner accordionList>
  68. {Array.from(Array(3).keys()).map(n => (
  69. <AccordionItem key={n}>
  70. <AccordionToggle><b>Item {n + 1}</b></AccordionToggle>
  71. <AccordionContent>Content {n + 1}</AccordionContent>
  72. </AccordionItem>
  73. ))}
  74. </Block>
  75. </Page>
  76. );