@molecule/app-collapsible-section-vue
Feature · collapsible-section · App (browser) · v1.1.4 · Apache-2.0
Expandable section with optional "show more / show less" and count
npm install @molecule/app-collapsible-section-vueHow it works
@molecule/app-collapsible-section-vue 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 { createApp, defineComponent, h } from 'vue'
import { CollapsibleSection, ShowMore } from '@molecule/app-collapsible-section-vue'
const App = defineComponent({
setup() {
return () =>
h(
CollapsibleSection,
{ title: 'Key concepts', defaultExpanded: true },
{
default: () => [h('p', 'Content revealed when expanded.')],
},
)
},
})
createApp(App).mount('#app')Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Vue 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 Vue counterpart of @molecule/app-collapsible-section-react:
the same props (React names) and the same DOM for the same input, with
ClassMap tokens and i18n keys unchanged.
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 { createApp, defineComponent, h } from 'vue'
import { CollapsibleSection, ShowMore } from '@molecule/app-collapsible-section-vue'
const App = defineComponent({
setup() {
return () =>
h(
CollapsibleSection,
{ title: 'Key concepts', defaultExpanded: true },
{
default: () => [h('p', 'Content revealed when expanded.')],
},
)
},
})
createApp(App).mount('#app')
Type
feature
Installation
npm install @molecule/app-collapsible-section-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
API
Interfaces
CollapsibleSectionProps
Props accepted by the CollapsibleSection component.
interface CollapsibleSectionProps {
/**
* Section heading — rendered as an expand-toggle button. Passed as a prop or
* as the same-named slot — both work.
*/
title?: VNodeChild
/** Body to show when expanded — the DEFAULT slot. */
children?: VNodeChild
/** 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 (prop or the same-named slot). */
badge?: VNodeChild
/** Optional right-side actions (prop or the same-named slot). */
actions?: VNodeChild
/** 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 — the DEFAULT slot. */
children?: VNodeChild
/** 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
}
Constants
CollapsibleSection
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.
const CollapsibleSection: DefineComponent<
ExtractPropTypes<{
title: null
children: null
expanded: null
defaultExpanded: null
onExpandedChange: { type: PropType<(expanded: boolean) => void>; default: undefined }
badge: null
actions: null
level: null
className: StringConstructor
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
title: null
children: null
expanded: null
defaultExpanded: null
onExpandedChange: { type: PropType<(expanded: boolean) => void>; default: undefined }
badge: null
actions: null
level: null
className: StringConstructor
}>
> &
Readonly<{}>,
{ onExpandedChange: (expanded: boolean) => void },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeCollapsibleSectionProps).
Returns: The collapsible section component.
ShowMore
"Show N more" / "Show less" toggle. Simpler than <CollapsibleSection> when
you just want to truncate a long list.
const ShowMore: DefineComponent<
ExtractPropTypes<{
children: null
initialCount: null
moreKey: { type: StringConstructor; default: string }
lessKey: { type: StringConstructor; default: string }
className: StringConstructor
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
children: null
initialCount: null
moreKey: { type: StringConstructor; default: string }
lessKey: { type: StringConstructor; default: string }
className: StringConstructor
}>
> &
Readonly<{}>,
{ moreKey: string; lessKey: string },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeShowMoreProps).
Returns: The show-more component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.0.1@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.13.0 || ^4.0.0vue^3.4.0
Runtime Dependencies
@molecule/app-ui@molecule/app-ui-vue@molecule/app-vuevue
<CollapsibleSection> is uncontrolled by default (defaultExpanded);
passing expanded makes it fully controlled — then you must update it from
onExpandedChange. Node-valued props (title, badge, actions) arrive as
a prop AND a same-named slot; the body is the default slot. 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).