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.

Install using CLI

AI Elements Vue
shadcn-vue CLI
npx ai-elements-vue@latest add commit

Install Manually

Copy and paste the following files into the same folder.

Commit.vue
CommitHeader.vue
CommitAuthor.vue
CommitAuthorAvatar.vue
CommitInfo.vue
CommitMessage.vue
CommitMetadata.vue
CommitHash.vue
CommitSeparator.vue
CommitTimestamp.vue
CommitActions.vue
CommitCopyButton.vue
CommitContent.vue
CommitFiles.vue
CommitFile.vue
CommitFileInfo.vue
CommitFileStatus.vue
CommitFileIcon.vue
CommitFilePath.vue
CommitFileChanges.vue
CommitFileAdditions.vue
CommitFileDeletions.vue
index.ts
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { Collapsible } from '@repo/shadcn-vue/components/ui/collapsible'
import { cn } from '@repo/shadcn-vue/lib/utils'

const props = defineProps<{
  class?: HTMLAttributes['class']
}>()
</script>

<template>
  <Collapsible
    :class="cn('rounded-lg border bg-background', props.class)"
    v-bind="$attrs"
  >
    <slot />
  </Collapsible>
</template>

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 />

...propsCollapsibleProps
Spread to the Collapsible component.

<CommitHeader />

...propsCollapsibleTriggerProps
Spread to the CollapsibleTrigger component.

<CommitAuthor />

...propsHTMLAttributes
Spread to the container div.

<CommitAuthorAvatar />

initialsrequiredstring
Author initials to display.
...propsAvatarProps
Spread to the Avatar component.

<CommitInfo />

...propsHTMLAttributes
Spread to the container div.

<CommitMessage />

...propsHTMLAttributes
Spread to the span element.

<CommitMetadata />

...propsHTMLAttributes
Spread to the container div.

<CommitHash />

...propsHTMLAttributes
Spread to the span element.

<CommitSeparator />

defaultSlot
Custom separator content. Defaults to "•".
...propsHTMLAttributes
Spread to the span element.

<CommitTimestamp />

daterequiredDate
Commit date.
defaultSlot
Custom timestamp content. Defaults to relative time.
...propsHTMLAttributes
Spread to the time element.

<CommitActions />

...propsHTMLAttributes
Spread to the container div.

<CommitCopyButton />

hashrequiredstring
Commit hash to copy.
timeoutnumber
Duration to show copied state (ms).
@copy() => void
Callback after successful copy.
@error(error: Error) => void
Callback if copying fails.
...propsButtonProps
Spread to the Button component.

<CommitContent />

...propsCollapsibleContentProps
Spread to the CollapsibleContent component.

<CommitFiles />

...propsHTMLAttributes
Spread to the container div.

<CommitFile />

...propsHTMLAttributes
Spread to the row div.

<CommitFileInfo />

...propsHTMLAttributes
Spread to the container div.

<CommitFileStatus />

statusrequired"added" | "modified" | "deleted" | "renamed"
File change status.
defaultSlot
Custom status label.
...propsHTMLAttributes
Spread to the span element.

<CommitFileIcon />

...propsLucideIconProps
Spread to the FileIcon component.

<CommitFilePath />

...propsHTMLAttributes
Spread to the span element.

<CommitFileChanges />

...propsHTMLAttributes
Spread to the container div.

<CommitFileAdditions />

countrequirednumber
Number of lines added.
...propsHTMLAttributes
Spread to the span element.

<CommitFileDeletions />

countrequirednumber
Number of lines deleted.
...propsHTMLAttributes
Spread to the span element.