
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-simple-expand
Advanced tools
React Component for creating accessible and performant expandable UI
React Component for creating accessible and performant expandable UI
We create similar info panels and accordion components that collapse and expand, to and from a height of zero. The logic is always the same but the look may change between use cases. Additionally, we want to have the component accessible to all users, at all times.
This is a WAI-ARIA compliant React component. It controls how panels/accordions/etc collapse and expand. ReactSimpleExpand uses render props to reduce overhead and give you flexibility in styling.
This module is distributed via npm which is bundled with node and
should be installed as one of your project's dependencies:
npm install --save react-simple-expand
class Accordion extends React.Component {
state = {
open: 0,
}
onClickItem = index => () => {
this.setState({open: index})
}
render() {
const {items} = this.props
const {open} = this.state
return items.map((item, index) => (
<ReactSimpleExpand
key={item.title}
onToggle={this.onClickItem(index)}
isOpen={open === index}
>
({(getRootProps, getHeaderProps, getContentProps)}) => (
<div {...getRootProps()}>
<button {...getHeaderProps()}>{item.title}</button>
<div {...getContentProps()}>{item.description}</div>
</div>
)}
</ReactSimpleExpand>
))
}
}
// Using the accordion
const App = () => (
<Accordion
items={[
{title: 'First item', description: 'This is just a demo.'},
{
title: "I'm the second item",
description:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque scelerisque mi sed sapien mollis tempor. Donec ut pretium mi, et mollis dolor. Donec fermentum, augue tristique dapibus facilisis, velit nisi mattis mi, sit amet ultrices arcu libero sed odio. Donec id nisl facilisis, luctus turpis vitae, egestas velit.',
},
{
title: 'Yup, this is the last item...',
description: 'Last but not least!',
},
]}
/>
)
requiredid: PropTypes.string.isRequired
Unique html id.
isOpen: PropTypes.bool
Controls the visibilty of the content. If the value changes after the first render, the component will change with an animation.
onToggle: PropTypes.func
onToggle is passed to the header element and called when clicked. This is the ideal place to
trigger a state change.
duration: PropTypes.number
If a value is supplied, the component will animate the toggle.
Note: This API is likely to change.
This is where you pass your own components to render the state of
ReactSimpleExpand. You can either use a prop called render, or use the
children prop.
The render prop function is passed an object that has the following properties:
These functions are used to apply props to the elements that you render. The functions take care composing event handlers, merging style objects and applying other important props and attributes to your components. Their API is all as follows:
@params {Object} props - optional props you want to add.
@returns {Object} - the props that you need to render the component.
Note: If you are rendering a composite component, that component
will need a prop called refKey. The refKey is used to forward a
required ref function that ReactSimpleExpand uses internally to
the root DOM element of the composite component. Commonly, folks
call this innerRef. So you'd call:
getRootProps({ refKey: 'innerRef' }) and your composite component
would forward like: <div ref={props.innerRef} />
| property | type | description |
|---|---|---|
| isOpen | boolean | Indicates the current visibility of the content. |
| isAnimating | boolean | Is true during state changes. |
FAQs
React Component for creating accessible and performant expandable UI
The npm package react-simple-expand receives a total of 511 weekly downloads. As such, react-simple-expand popularity was classified as not popular.
We found that react-simple-expand demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.