Adding Support for Deleting Items
Learn how to delete existing items with the help of confirmation modals.
We'll cover the following...
In this lesson, we're going to look at how we can introduce a delete button to our details page, with a confirmation pop-up to avoid accidental deletes. First, let's start off by introducing the delete button to the details page. Scroll down to line 66 in the example below to see the partial implementation.
<svg width="13" height="12" viewBox="0 0 13 12" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M0.599952 0.599999C0.931323 0.268629 1.44172 0.241766 1.73995 0.539999L11.4599 10.26C11.7582 10.5582 11.7313 11.0686 11.3999 11.4C11.0686 11.7313 10.5582 11.7582 10.2599 11.46L0.539953 1.74C0.241719 1.44176 0.268582 0.931369 0.599952 0.599999Z" fill="#222222"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M11.6308 0.600013C11.9622 0.931384 11.9891 1.44178 11.6908 1.74001L1.97086 11.46C1.67262 11.7582 1.16223 11.7314 0.830858 11.4C0.499488 11.0686 0.472625 10.5582 0.770858 10.26L10.4908 0.540014C10.7891 0.24178 11.2995 0.268643 11.6308 0.600013Z" fill="#222222"/> </svg>
Add a delete button to the Details view
Notice that for the correct alignment, we need to introduce an extra wrapper on line 55 for aligning the flex
items. In order to align the two elements (the registration date with the check, and the delete button) on each side, we can use the justify-between
rule to apply a justify-content: space-between
...