<SoftDeleteWithConfirmButton>

Soft-deletes the current record after a confirm dialog has been accepted.

Usage

import * as React from 'react';
import { Toolbar, Edit, SaveButton, useRecordContext } from 'react-admin';
import { SoftDeleteWithConfirmButton } from '@react-admin/ra-soft-delete';

const EditToolbar = () => {
    const record = useRecordContext();

    return (
        <Toolbar>
            <SaveButton/>
            <SoftDeleteWithConfirmButton
                confirmContent="You will be able to recover this record from the trash."
                confirmColor="warning"
                contentTranslateOptions={{ name: record.name }}
                titleTranslateOptions={{ name: record.name }}
            />
        </Toolbar>
    );
};

const MyEdit = () => (
    <Edit>
        <SimpleForm toolbar={<EditToolbar />}>
            ...
        </SimpleForm>        
    </Edit>    
);

Props

Prop Required Type Default Description
className Optional string - Class name to customize the look and feel of the button element itself
confirmTitle Optional ReactNode ‘ra-soft-delete. message. soft_delete_title’ Title of the confirm dialog
confirm Content Optional ReactNode ‘ra-soft-delete. message. soft_delete_content’ Message or React component to be used as the body of the confirm dialog
confirmColor Optional 'primary' | 'warning' ‘primary’ The color of the confirm dialog’s “Confirm” button
content Translate Options Optional Object {} Custom id, name and record representation to be used in the confirm dialog’s content
icon Optional ReactElement <DeleteIcon> iconElement, e.g. <CommentIcon />
label Optional string ‘ra-soft-delete. action. soft_delete’ label or translation message to use
mutation Options Optional   null options for react-query useMutation hook
redirect Optional string | false | Function ‘list’ Custom redirection after success side effect
title Translate Options Optional Object {} Custom id, name and record representation to be used in the confirm dialog’s title
success Message Optional string ‘ra-soft-delete. notification. soft_deleted’ Lets you customize the success notification message.