Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
solid-collapse
Advanced tools
Tiny and performant collapse component for SolidJS.
Prop | Description | Type | Default | Required |
---|---|---|---|---|
value | Boolean value to control collapse | boolean | true | :white_check_mark: |
class | Class with a (height)transition property | string | '' | :white_check_mark: |
as | Element tag to render instead of div | string | div | :x: |
onExpanded | Callback on expand transition completed. | () => void | () => {} | :x: |
onCollapsed | Callback on collapse transition completed | () => void | () => {} | :x: |
id
, role
and aria-labelledby
are also supported.
yarn add solid-collapse
# npm i -S solid-collapse
# pnpm add solid-collapse
1. In a CSS file:
.my-transition {
transition: height 300ms cubic-bezier(0.65, 0, 0.35, 1);
}
2. In a component file:
import { createSignal } from 'solid-js';
import { Collapse } from 'solid-collapse';
const App = () => {
const [isExpanded, setIsExpanded] = createSignal(false);
return (
<div>
<button onClick={() => setIsExpanded(!isExpanded())}>Expand me</button>
<Collapse value={isExpanded()} class="my-transition">
<p class="my-content-class">
I am a bunch of collapsed text that wants to be expanded
</p>
</Collapse>
</div>
);
};
Solid Collapse automatically calculates the optimal duration according to the content height. You can opt-it by referencing the variable --sc-auto-duration
in your transition property:
.my-transition {
transition: height var(--sc-auto-duration) cubic-bezier(0.65, 0, 0.35, 1);
}
Please check the examples on the demo website.
Assigning a ref
to Collapse is not possible. If you need to access its DOM node, you can call document.getElementById
inside an onMount
callback.
You will have to make your UI compliant by manually implementing ARIA practices. Don't worry any example shows how to do that.
MIT Licensed. Copyright (c) Simone Mastromattei 2022.
FAQs
Tiny and performant collapse component for SolidJS.
The npm package solid-collapse receives a total of 507 weekly downloads. As such, solid-collapse popularity was classified as not popular.
We found that solid-collapse 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.