Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@commercetools-uikit/collapsible
Advanced tools
Readme
A render-prop component to manage a toggle state. The component can be controlled or uncontrolled, depending if the isClosed
props is defined or not. A controlled component additionally requires the onToggle
prop.
yarn add @commercetools-uikit/collapsible
npm --save install @commercetools-uikit/collapsible
Additionally install the peer dependencies (if not present)
yarn add react
npm --save install react
import Collapsible from '@commercetools-uikit/collapsible';
const Example = () => (
<Collapsible>
{({ isOpen, toggle }) => (
<div>
<div>Status: {isOpen ? 'open' : 'closed'}</div>
<button onClick={toggle}>Toggle</button>
</div>
)}
</Collapsible>
);
export default Example;
Props | Type | Required | Default | Description |
---|---|---|---|---|
isDefaultClosed | boolean | false | This is only used to initialize the isOpen state once, when the component mounts.
Therefore there should not be any componentWillReceiveProps to update the state
from an external source. | |
children | Function See signature. | ✅ | A render-prop function.
children will be called with options: { isOpen: boolean; toggle: TToggleCallback }
options.toggle will be defined given that Collapsible is a controlled component. | |
isClosed | boolean | Passing this prop makes the component a controlled component.
Controlled components also require to pass a onToggle callback function. | ||
onToggle | Function See signature. | A callback function, called when the consumer calls the toggle function.
This function is only required when the component is controlled. |
children
(options: { isOpen: boolean; toggle?: TToggleCallback }) => ReactNode;
onToggle
(toggleState?: boolean) => void
FAQs
A render-prop component to manage a toggle state
The npm package @commercetools-uikit/collapsible receives a total of 3,579 weekly downloads. As such, @commercetools-uikit/collapsible popularity was classified as popular.
We found that @commercetools-uikit/collapsible demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.