Skip to Content

Fold

Long text behind one row, with a Show more link. Opens in place, no popup.

Builder notes12 lines, written by the builder
import { Fold } from "@dapplelight/signet-ui/components/fold"

const notes = `Changed **packages/ui** only.

- Added the Fold component and its tests
- Reused Markdown for the body`

export function Demo() {
  return (
    <Fold title="Builder notes" detail="12 lines, written by the builder">
      {notes}
    </Fold>
  )
}

Installation

npm i @dapplelight/signet-ui

The body is rendered by Markdown, so Fold needs its optional peers (react-markdown, remark-gfm, remark-parse, unified, github-slugger). That is why it is imported from components/fold and not the barrel.

Usage

import { Fold } from "@dapplelight/signet-ui/components/fold"

<Fold title="Builder notes" detail="12 lines, written by the builder">
  {markdown}
</Fold>

The toggle is a real button: Enter and Space work, aria-expanded announces open or closed, and aria-controls points at the text. The text is capped at about 66 characters wide.

Examples

Open at first

Builder notes12 lines, written by the builder

Changed packages/ui only.

  • Added the Fold component and its tests
  • Reused Markdown for the body, so links and lists render safely
  • Left every existing component as it was

Run bun run test in packages/ui to check it.

<Fold title="Builder notes" detail="12 lines, written by the builder" defaultOpen>
  {markdown}
</Fold>

Your own words and styles

Release noteswritten by the team
<Fold
  title="Release notes"
  detail="written by the team"
  showMoreLabel="Read on"
  showLessLabel="Fold up"
  classNames={{ detail: "italic" }}
>
  {markdown}
</Fold>

Customising

  • Tokens: it uses theme utilities only, so a theme change restyles it.
  • Words: showMoreLabel / showLessLabel, or showMore / showLess once for the app through LabelsProvider.
  • Classes and state: className, classNames per part (header, title, detail, toggle, body, markdown) and data-state="open|closed".
  • Parts: FoldRoot, FoldHeader, FoldTitle, FoldDetail, FoldToggle, FoldBody to build your own row (a badge in the header, plain text in the body).
  • Own the code: signet add fold copies the file in.

API Reference

Fold

PropTypeDefaultDescription
titleReactNode-The row's title.
detailReactNode-Muted text beside the title.
childrenstring-The long text, as Markdown.
openboolean-Controlled state.
defaultOpenbooleanfalseStart open.
onOpenChange(open: boolean) => void-Called when the link is used.
showMoreLabelstring"Show more"Link text while closed.
showLessLabelstring"Show less"Link text while open.
markdownOmit<MarkdownProps, "children">-Passed to the Markdown renderer.
classNames{ header?; title?; detail?; toggle?; body?; markdown? }-Class per part.