Guide
Components
Diff

Diff Component

ℹ️

The Diff component is a versatile React component designed to display a visual difference or comparison between two items, either images or text. It leverages the class-variance-authority library to handle variants and provides an interactive visual comparison with a resizable divider.

Example Preview

Diff Example

Options

ℹ️

The following options are available for the Diff component:

OptionDescriptionDefault
classNameThe class name for the component.''
variantThe variant type, can be 'default', 'image', or 'text'.'text'
srcURL for the first image in 'image' variant.Default placeholder image URL
src_bwURL for the second (black and white) image in 'image' variant.Default placeholder image URL
altAlternative text for the images.'' (empty string for default)
textText content for the 'text' variants.'DAISY'

Example Usage

ℹ️

The following example shows how to use the Diff component:

import React from "react";
import { Diff } from "@/@core";
 
export const MyVisualComparison = () => (
  <Diff
    variant="image"
    src="https://example.com/image1.jpg"
    src_bw="https://example.com/image2.jpg"
  />
);

Customization Options

ℹ️

The following customization options are available for the Diff component:

OptionDescriptionDefault
classNameThe class name for the component.''
variantThe variant type, can be 'default', 'image', or 'text'.'text'
srcURL for the first image in 'image' variant.Default placeholder image URL
src_bwURL for the second (black and white) image in 'image' variant.Default placeholder image URL
altAlternative text for the images.'' (empty string for default)
textText content for the 'text' variants.'DAISY'

Props Table

ℹ️

The following props table shows the available props for the Diff component:

NameTypeDefaultDescription
classNamestring''The class name for the component.
variantstring'text'The variant type, can be 'default', 'image', or 'text'.
srcstringDefault placeholder image URLURL for the first image in 'image' variant.
src_bwstringDefault placeholder image URLURL for the second (black and white) image in 'image' variant.
altstring''Alternative text for the images.
textstring'DAISY'Text content for the 'text' variants.

Diff Variants

ℹ️

The following variants are available for the Diff component:

  • Variant Types:
    • 'default'
    • 'image'
    • 'text'
ℹ️

The Diff component relies on class-variance-authority (opens in a new tab) for handling variants. Adjust the default values and styling according to your design requirements.