npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cujuju/solidjs-collapsible

v0.1.0

Published

Collapsible section for SolidJS — persisted open state, forceOpen override, panel + section variants, full a11y.

Readme

@cujuju/solidjs-collapsible

Collapsible section for SolidJS. Persisted open state, forceOpen override with manual-toggle semantics, 'section' and 'panel' visual variants, full a11y (aria-expanded / aria-controls / role="region"), keyboard-friendly.

Install

pnpm add @cujuju/solidjs-collapsible

Stylesheet auto-imported via entrypoint (or import @cujuju/solidjs-collapsible/styles.css manually).

Usage

import { Collapsible } from '@cujuju/solidjs-collapsible';

<Collapsible
  title="Filters"
  storageKey="search-filters"
  storageKeyPrefix="myapp:section:"
  count={activeFilters().length}
>
  <FiltersPanel />
</Collapsible>

Hook + component

  • useCollapsible is the state-machine hook (for consumers who want custom visuals).
  • <Collapsible> is the batteries-included component.
import { useCollapsible } from '@cujuju/solidjs-collapsible';

const state = useCollapsible({ storageKey: 'myapp:filters' });
<button onClick={state.toggle}>
  {state.open() ? 'Collapse' : 'Expand'}
</button>
<Show when={state.open()}>...content...</Show>

API

<Collapsible> props

| Prop | Default | Description | |---|---|---| | title | (required) | string or JSX. | | children | (required) | Content body. | | count | — | Optional number rendered as (N) after the title. | | actions | — | Right-aligned JSX in the header row. | | icon | | Single icon; rotates 90° when open. | | openIcon, closedIcon | — | Distinct icons per state (overrides icon). | | storageKey | — | localStorage key for persistence. If omitted, state is ephemeral. | | storageKeyPrefix | '' | Prefix prepended to storageKey. Empty by default — consumers control their own namespace. | | defaultOpen | true | Initial value when no persisted state exists. | | forceOpen | — | Override value (e.g., from an "expand all" button). See semantics below. | | onChange(open) | — | Fires whenever the effective open state changes. | | uppercase | false | Applies uppercase + letter-spacing to the title. | | variant | 'section' | 'section' (transparent header) or 'panel' (card with background + border). | | lazyMount | false | Render children only after first open. | | keepMounted | true | Keep DOM when closed (hidden via CSS). Set false to unmount on close. | | animated | false | Animate content height on toggle. | | ariaLabel, id | — | a11y hooks. | | class, headerClass, contentClass | — | Style passthrough. |

useCollapsible(options)

Same state-related options as the component plus forceOpen is an accessor (() => boolean | null | undefined) rather than a value.

Returns { open, toggle, setOpen, manuallyToggled, reset }.

forceOpen + manuallyToggled semantics

Designed for "Expand All" / "Collapse All" buttons where the user can still override per-section:

forceOpen: null              → section respects its own local state
forceOpen: true              → section opens (unless manuallyToggled is true)
user toggles (open→closed)   → manuallyToggled = true; user's choice sticks
forceOpen: true (unchanged)  → no effect; user's choice still wins
forceOpen: false             → NEW value: manuallyToggled resets, section closes
forceOpen: true              → NEW value: manuallyToggled resets, section opens

Detection is by value: re-asserting the same forceOpen value is a no-op. Only a change to a different value resets manuallyToggled.

Theming

:root {
  --cl-arrow-color-open: #64748b;
  --cl-arrow-color-closed: #f59e0b;
  --cl-title-color: #64748b;
  --cl-title-size: 14px;
  --cl-title-weight: 600;
  --cl-title-tracking: 0.08em;
  --cl-count-color: #94a3b8;
  --cl-panel-bg: #1e293b;
  --cl-panel-border: #334155;
  --cl-panel-radius: 4px;
  --cl-animation-duration: 180ms;
}

A11y

  • Header: <button> with aria-expanded + aria-controls.
  • Content: role="region" with aria-labelledby pointing back to the header id.
  • Arrow icons: aria-hidden="true" (decorative).
  • Space/Enter toggle (native button behavior).
  • prefers-reduced-motion disables arrow rotation and height transitions.

Animation caveat

When animated={true}, the open→close transition uses max-height. If the content height changes while open (e.g., a list grows), the transition on the NEXT close will time against the stale height. Content is rendered normally — this is not a visible-overflow bug, just potentially an animation-timing oddity. Wire up a ResizeObserver yourself to re-measure if your content is dynamic and you care about the close-animation accuracy.

License

MIT