Commit

Display commit information with hash, message, author, and file changes.

The Commit component displays commit details including hash, message, author, timestamp, and changed files.

See scripts/commit.tsx for this example.

Installation

npx ai-elements@latest add commit

Features

  • Commit hash display with copy button
  • Author avatar with initials
  • Relative timestamp formatting
  • Collapsible file changes list
  • Color-coded file status (added/modified/deleted/renamed)
  • Line additions/deletions count

File Status

StatusLabelColor
addedAGreen
modifiedMYellow
deletedDRed
renamedRBlue

Props

<Commit />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof Collapsible>-Spread to the Collapsible component.

<CommitHeader />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof CollapsibleTrigger>-Spread to the CollapsibleTrigger component.

<CommitAuthor />

PropTypeDefaultDescription
...propsReact.HTMLAttributes<HTMLDivElement>-Spread to the container div.

<CommitAuthorAvatar />

PropTypeDefaultDescription
initialsstringRequiredAuthor initials to display.
...propsReact.ComponentProps<typeof Avatar>-Spread to the Avatar component.

<CommitInfo />

PropTypeDefaultDescription
...propsReact.HTMLAttributes<HTMLDivElement>-Spread to the container div.

<CommitMessage />

PropTypeDefaultDescription
...propsReact.HTMLAttributes<HTMLSpanElement>-Spread to the span element.

<CommitMetadata />

PropTypeDefaultDescription
...propsReact.HTMLAttributes<HTMLDivElement>-Spread to the container div.

<CommitHash />

PropTypeDefaultDescription
...propsReact.HTMLAttributes<HTMLSpanElement>-Spread to the span element.

<CommitSeparator />

PropTypeDefaultDescription
childrenReact.ReactNode-Custom separator content.
...propsReact.HTMLAttributes<HTMLSpanElement>-Spread to the span element.

<CommitTimestamp />

PropTypeDefaultDescription
dateDateRequiredCommit date.
childrenReact.ReactNode-Custom timestamp content. Defaults to relative time.
...propsReact.HTMLAttributes<HTMLTimeElement>-Spread to the time element.

<CommitActions />

PropTypeDefaultDescription
...propsReact.HTMLAttributes<HTMLDivElement>-Spread to the container div.

<CommitCopyButton />

PropTypeDefaultDescription
hashstringRequiredCommit hash to copy.
onCopy() => void-Callback after successful copy.
onError(error: Error) => void-Callback if copying fails.
timeoutnumber2000Duration to show copied state (ms).
...propsReact.ComponentProps<typeof Button>-Spread to the Button component.

<CommitContent />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof CollapsibleContent>-Spread to the CollapsibleContent component.

<CommitFiles />

PropTypeDefaultDescription
...propsReact.HTMLAttributes<HTMLDivElement>-Spread to the container div.

<CommitFile />

PropTypeDefaultDescription
...propsReact.HTMLAttributes<HTMLDivElement>-Spread to the row div.

<CommitFileInfo />

PropTypeDefaultDescription
...propsReact.HTMLAttributes<HTMLDivElement>-Spread to the container div.

<CommitFileStatus />

PropTypeDefaultDescription
statusunknownRequiredFile change status.
childrenReact.ReactNode-Custom status label.
...propsReact.HTMLAttributes<HTMLSpanElement>-Spread to the span element.

<CommitFileIcon />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof FileIcon>-Spread to the FileIcon component.

<CommitFilePath />

PropTypeDefaultDescription
...propsReact.HTMLAttributes<HTMLSpanElement>-Spread to the span element.

<CommitFileChanges />

PropTypeDefaultDescription
...propsReact.HTMLAttributes<HTMLDivElement>-Spread to the container div.

<CommitFileAdditions />

PropTypeDefaultDescription
countnumberRequiredNumber of lines added.
...propsReact.HTMLAttributes<HTMLSpanElement>-Spread to the span element.

<CommitFileDeletions />

PropTypeDefaultDescription
countnumberRequiredNumber of lines deleted.
...propsReact.HTMLAttributes<HTMLSpanElement>-Spread to the span element.