Accordion
Collapse allows users to show or hide grouped content.
Examples
1. How do I create an egg wash?
To create an egg wash, whisk together a large egg with one tablespoon of water until smooth. Use as a glue to seal pastries, then brush on top for a glossy appearance.
2. How do I easily peel tomatoes?
Peel tomatoes with ease! Cut an X in the top, and then simmer in a pot of hot water for 15 to 30 seconds. Cool down and the skin will fall right off.
1. How do I create an egg wash?
To create an egg wash, whisk together a large egg with one tablespoon of water until smooth. Use as a glue to seal pastries, then brush on top for a glossy appearance.
2. How do I easily peel tomatoes?
Peel tomatoes with ease! Cut an X in the top, and then simmer in a pot of hot water for 15 to 30 seconds. Cool down and the skin will fall right off.
import React from 'react';
import ReactDOM from 'react-dom';
import { Accordion, Collapse } from 'furl-components';
ReactDOM.render(
<div>
<Accordion>
<Collapse title="1. How do I create an egg wash?">
To create an egg wash, whisk together a large egg with one tablespoon of water until smooth. Use as a glue to seal pastries, then brush on top for a glossy appearance.
</Collapse>
<Collapse title="2. How do I easily peel tomatoes?">
Peel tomatoes with ease! Cut an X in the top, and then simmer in a pot of hot water for 15 to 30 seconds. Cool down and the skin will fall right off.
</Collapse>
</Accordion>
<Accordion
fill='flat'
openIndex={1}
data={[
{
title: '1. How do I create an egg wash?',
content: 'To create an egg wash, whisk together a large egg with one tablespoon of water until smooth. Use as a glue to seal pastries, then brush on top for a glossy appearance.'
},
{
title: '2. How do I easily peel tomatoes?',
content: 'Peel tomatoes with ease! Cut an X in the top, and then simmer in a pot of hot water for 15 to 30 seconds. Cool down and the skin will fall right off.'
}
]}
/>
</div>,
document.getElementById('root')
);
API
Property | Description | Type | Default | ||
---|---|---|---|---|---|
openIndex | accordion selected index | int | 0 | ||
fill | accordion fill style | string | 'solid' | ||
data | accordion data source | array(object) |
Notes
- You can populate an accordion either via passing children to it or via the use of the
data
prop. Ifdata
is provided, it will take precedence over passed children, therefore rendering only the content provided indata
. - An
Accordion
only accepts children of theCollapse
component type. data
only accepts an array of object values. Objects in thedata
array must contain atitle
and acontent
value. The latter can either be a string or an object, allowing you to pass React component trees.openIndex
can only be an integer between0
and however many children ordata
values the accordion has minus one (inclusive) - i.e. the zero-based index of the selected accordion item.fill
can be either'solid'
or'flat'
and will override thefill
property of any of the component’s children.