@molecule/app-collapsible-section-solid
Feature · collapsible-section · App (browser) · v1.1.5 · Apache-2.0
Expandable section with optional "show more / show less" and count
npm install @molecule/app-collapsible-section-solidHow it works
@molecule/app-collapsible-section-solid is a ready-made collapsible-section feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { render } from 'solid-js/web'
import { MoleculeProvider } from '@molecule/app-solid'
import { CollapsibleSection, ShowMore } from '@molecule/app-collapsible-section-solid'
render(
() => (
<MoleculeProvider i18n={i18nProvider}>
<CollapsibleSection title="Key concepts" defaultExpanded={true}>
<p>Content revealed when expanded.</p>
</CollapsibleSection>
<ShowMore initialCount={3}>
{items.map((item) => (
<div>{item.label}</div>
))}
</ShowMore>
</MoleculeProvider>
),
document.getElementById('root')!,
)Works with: @molecule/app-solid, @molecule/app-ui, @molecule/app-ui-solid
Reference
Solid collapsible-section and show-more.
Exports:
<CollapsibleSection>— expandable section with a clickable heading.<ShowMore>— "Show N more" / "Show less" toggle for long lists.
It is the Solid counterpart of @molecule/app-collapsible-section-react:
the same props (React names), the same ClassMap tokens, the same i18n keys,
and the same DOM for the same input.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { render } from 'solid-js/web'
import { MoleculeProvider } from '@molecule/app-solid'
import { CollapsibleSection, ShowMore } from '@molecule/app-collapsible-section-solid'
render(
() => (
<MoleculeProvider i18n={i18nProvider}>
<CollapsibleSection title="Key concepts" defaultExpanded={true}>
<p>Content revealed when expanded.</p>
</CollapsibleSection>
<ShowMore initialCount={3}>
{items.map((item) => (
<div>{item.label}</div>
))}
</ShowMore>
</MoleculeProvider>
),
document.getElementById('root')!,
)
Type
feature
Installation
npm install @molecule/app-collapsible-section-solid @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js
API
Interfaces
CollapsibleSectionProps
Props accepted by the CollapsibleSection component.
interface CollapsibleSectionProps {
/** Section heading — rendered as an expand-toggle button. */
title?: JSX.Element
/** Body to show when expanded. */
children?: JSX.Element
/** Controlled expansion — if omitted, the component owns state. */
expanded?: boolean
/** Initial expanded state when uncontrolled. Defaults to false. */
defaultExpanded?: boolean
/** Called when expansion state changes. */
onExpandedChange?: (expanded: boolean) => void
/** Optional badge / count shown in the header. */
badge?: JSX.Element
/** Optional right-side actions. */
actions?: JSX.Element
/** Heading level — affects rendered tag, defaults to 3. */
level?: 2 | 3 | 4 | 5 | 6
/** Extra classes. */
className?: string
}
ShowMoreProps
Props accepted by the ShowMore component.
interface ShowMoreProps {
/**
* Items before truncation: plain JSX, or accessor items (`() => <Row />`), which are created
* only when shown. A row may have any root, a `<Show>` or a fragment included.
*/
children?: NodeItems
/** Number to show initially. Defaults to 3. */
initialCount?: number
/** i18n key for the "Show more" label — receives `{ remaining }`. */
moreKey?: string
/** i18n key for the "Show less" label. */
lessKey?: string
/** Extra classes. */
className?: string
}
Functions
CollapsibleSection(props)
Expandable section with a clickable heading. Lighter-weight than
<Accordion> — renders a single toggle, not a group of panels.
Expansion is uncontrolled by default (defaultExpanded); pass expanded to
control it — then update it from onExpandedChange. The header renders a
toggle <button> around the label with actions beside it as a sibling
(a button may not contain other controls), so actions MAY contain
buttons/links — a click there never reaches the toggle.
function CollapsibleSection(props: CollapsibleSectionProps): JSX.Element
props— Component props (seeCollapsibleSectionProps).
Returns: The rendered collapsible section.
ShowMore(props)
"Show N more" / "Show less" toggle. Simpler than <CollapsibleSection> when
you just want to truncate a long list.
Items it does not show are not created when each is written as an accessor (() => <Row />,
in an array; the prop is typed NodeItems): an item is created when it comes into view and
disposed when it leaves, as React mounts it, and keeps its state while it stays. A row may have
any root, a <Show> or a fragment included. Plain JSX children (<Row />) are created when
the list is read, which is Solid's own rule, so a row with state, effects or a fetch is written
as an accessor. For a list that changes, build the accessors with mapArray, so a row that
stays keeps its identity (and its state), as React keeps a keyed element; rows().map(…)
makes new accessors, so new rows, on every change. A single accessor written alone
({() => <Row />}, no array) is read as a dynamic list and created when counted.
function ShowMore(props: ShowMoreProps): JSX.Element
props— Component props (seeShowMoreProps).
Returns: The rendered show-more list.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-solid^3.15.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-solid^1.1.0solid-js^1.8.0
Runtime Dependencies
@molecule/app-solid@molecule/app-ui@molecule/app-ui-solidsolid-js
<CollapsibleSection> is uncontrolled by default (defaultExpanded);
passing expanded makes it fully controlled — then you must update it from
onExpandedChange. The header renders as a single <button>, so anything
passed to actions must NOT contain buttons/links (nested interactive
elements are invalid HTML) — put row actions outside the section instead.
<ShowMore>'s labels use the i18n keys showMore.more / showMore.less
with English defaultValues; no companion locale bond ships these keys —
add them to your app's locale resources (or pass custom
moreKey/lessKey).