JGuang

Collapsible

Collapsible · Chakra UI

Preview
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0

Collapsible

Used to expand and collapse additional content.

Associate a single trigger and content region. Choose controlled state and lazy mounting deliberately, and avoid hiding a still-focused input when collapsing.

Included icon notices

The source viewer includes ICON_ATTRIBUTION.md and original notices for the icon collections used by these examples. Preserve them when redistributing examples; react-icons' wrapper license does not replace individual collection terms.

  • Lucide: ISC

Installation and initialization

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0

Initialize ChakraProvider with defaultSystem and Emotion before rendering. Preserve the host React version and inspect peer compatibility. Official npm installation supplies components, not these example source files. Use the resource setup guide for locale, next-themes and framework-specific SSR; copy the selected example source separately from npm installation.

Complete native usage example

This is the actual pinned example, not a generic API mock. Copy its source closure and retain the named export. Additional imports are listed per example below.

import { Box, Collapsible } from "@chakra-ui/react"

export const CollapsibleBasic = () => (
  <Collapsible.Root>
    <Collapsible.Trigger paddingY="3">Toggle Collapsible</Collapsible.Trigger>
    <Collapsible.Content>
      <Box padding="4" borderWidth="1px">
        <strong>Chakra UI</strong> embraces this philosophy in the world of
        design and development. Just like chakras align energy in the body,
        Chakra UI aligns your design system — bringing flow, consistency, and
        peace of mind to your codebase. It helps developers focus on creating
        beautiful, accessible UIs without friction.
        <br />
        <br />
        Think of each component as a wheel in your app’s UI — smooth, connected,
        and full of potential. Build with harmony. Build with
        <strong>Chakra UI</strong>.
      </Box>
    </Collapsible.Content>
  </Collapsible.Root>
)

All examples and reproduction requirements

Names identify demos, not component variant props. Copy every sourceFiles entry for the selected example. The compositions alias denotes local files, not a package. Preserve relative imports or rewrite the alias to your project's actual path. React peers are inspected separately; editor examples retain the coherent pinned Tiptap extension family.

Basic

collapsible-basic · Named export CollapsibleBasic · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/collapsible-basic.tsx

Initial Open

collapsible-initial-open · Named export CollapsibleInitialOpen · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 prop-types@15.8.1 react-icons@5.6.0 react-lorem-ipsum@1.4.10
  • vendor/apps/compositions/src/examples/collapsible-initial-open.tsx

Partial Height

collapsible-partial-height · Named export CollapsiblePartialHeight · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 prop-types@15.8.1 react-icons@5.6.0 react-lorem-ipsum@1.4.10
  • vendor/apps/compositions/src/examples/collapsible-partial-height.tsx

With Disabled

collapsible-with-disabled · Named export CollapsibleWithDisabled · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/collapsible-with-disabled.tsx

Controlled

collapsible-controlled · Named export CollapsibleControlled · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/collapsible-controlled.tsx

With Store

collapsible-with-store · Named export CollapsibleWithStore · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
  • vendor/apps/compositions/src/examples/collapsible-with-store.tsx

Lazy Mounted

collapsible-lazy-mounted · Named export CollapsibleLazyMounted · original upstream example

npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
  • vendor/apps/compositions/src/examples/collapsible-lazy-mounted.tsx

Native API and source references

The source viewer retains original declarations, imports and inheritance. Ark UI event contracts, Chakra style props and recipe types stay in their native packages; this guide does not flatten or invent their defaults. Code comments remain original source, not translated prose.

  • npm/@chakra-ui/react@3.37.0/dist/types/components/collapsible/collapsible.d.ts
  • npm/@chakra-ui/react@3.37.0/dist/types/components/collapsible/index.d.ts
  • npm/@chakra-ui/react@3.37.0/dist/types/components/collapsible/namespace.d.ts

Scoped Vite 8 interoperability

Some examples here import react-lorem-ipsum@1.4.10. The verified Vite 8 consumer uses the included authored/native-package-interop.mjs helper in its plugins list: chakraNativePackageInterop(process.cwd()). Copy that helper into the consuming build config and adjust the import path. This unwraps the package's native CommonJS default; it does not replace the component. Apply only when this export mismatch is reproduced; other bundlers may not need it.

State and installation checks

Run strict types, the target production build and real interactions. Test labels/focus/keyboard, both themes, narrow layout, empty/loading/error states where supported and cleanup after unmount. Remote demo endpoints, uploads and downloads are constrained in the preview; configure your own services. Copying a command or reaching preview-ready does not prove installation or backend success.

Provenance and license boundaries

https://github.com/chakra-ui/chakra-ui/tree/2e7517745cff2fcde0b8012f136cf99611ff262a

These are JGuang practical bilingual notes, not a full translation of upstream MDX. Original documentation and example bytes remain in vendor. Preserve repository MIT, compositions ISC metadata and separate dependency notices. The original metadata discrepancy and any missing full notices remain explicit review items; paid Chakra Pro is excluded.