Delete
Overview
The Delete component provides a Bulma-styled close/delete button for dismissing modals, notifications, tags, messages, and more.
It supports Bulma size and color helpers, and includes accessibility best practices.
This component is ideal for adding a visually consistent, accessible close button to any Bulma-styled element.
Import
import { Delete } from '@allxsmith/bestax-bulma';
Usage
Default Delete
The default usage of the Delete component renders a Bulma-styled close button. Use this for dismissing modals, notifications, tags, or any element that needs a consistent close/delete action.
<Delete />
Small, Medium, Large
The size prop allows you to adjust the button size. Use size="small", size="medium", or size="large" to match the context of your UI.
<Group> <Delete size="small" /> <Delete size="medium" /> <Delete size="large" /> </Group>
Disabled
The disabled prop disables the button, making it non-interactive and visually muted. Use this when the close action should be temporarily unavailable.
<Delete disabled />
With Custom Class
Add your own CSS classes with the className prop to further customize the delete button's appearance or behavior.
<Delete className="custom-delete" />
With Text Color
Set the text color using the textColor prop. For example, textColor="primary" applies Bulma's primary color to the button.
<Delete textColor="primary" />
With Background Color
Apply a background color using the bgColor prop. Here, bgColor="info" gives the button a colored background.
<Delete bgColor="info" />
With Margin
You can use Bulma spacing helpers like m to add margin around the button for better layout control.
<Delete m="2" />
In a Tag
The Delete component is often used inside a Tag for removable labels. This example shows a small, colored delete button inside a tag.
<Tag color="info" size="medium"> Example Tag <Delete size="small" textColor="danger" ariaLabel="Remove tag" /> </Tag>
In a Notification
Use the Delete component inside a Notification to provide a dismiss action for alerts or messages. The notification pads its end so the text clears a Delete placed directly inside it, at any size, in browsers that support :has(). Notification's own hasDelete prop renders the button and leaves that room without depending on :has().
<Notification color="primary"> <Delete ariaLabel="Close notification" /> <Paragraph>This is a primary notification with a delete button.</Paragraph> </Notification>
In a Message Header
The Delete component can be placed in a message header for dismissible messages. Combine with spacing and color props for best results.
<Message color="success" title="Success Message"> This is a success message with a delete button in the header. </Message>
Accessibility
- ARIA label: Always set a meaningful
ariaLabelfor screen readers (default is'Close'). - Keyboard: The button is focusable and supports keyboard activation.
- Forms: It renders
type="button", so a delete button inside a form doesn't submit it. - Disabled: Uses both
disabledand Bulma’sis-disabledfor proper styling and accessibility. - Target size: Bulma draws the button smaller than WCAG 2.5.8's 24px minimum target size at its default and small sizes. A transparent box inside it, which bestax's styles make at least 24px square and centre on it, takes its presses too, so a press just beside the circle still reaches it, and the circle shows its hover shade there. The circle and the layout around it stay as Bulma draws them. The box reaches past a smaller circle, over whatever sits that close, so give a small one room, as the sizes example above does. The other close and remove buttons bestax draws as a
.deletehave the same box, and so does the Modal's floating close. Under Bulma's own CSS alone the box does nothing. A<button class="delete">you write yourself has no box, so renderDeleteinstead. ADeletegivendangerouslySetInnerHTMLhas none either, since React won't render the box beside it. - Forced colors: Bulma draws the circle and the cross as background colors, which forced colors (Windows' contrast themes) replaces, so the button would vanish there while it still works and takes focus. bestax's styles keep it drawn in the system's button colors, with its focus ring in the system's highlight color, and a disabled one, or one inside a disabled
<fieldset>, in the system's color for disabled controls. Every close button bestax renders is drawn as a.delete, apart from the Modal's floating close, a Tag withisDelete, and the Sidebar'sSidebar.Close, and those keep their crosses in the system's colors too.
For custom close actions, use the onClick prop.
Related Components
Notification: For dismissible alerts.Tag: For removable tag UI.Message: For dismissible messages.- Helper Props: Bulma helper props for spacing, color, etc.
Additional Resources
Props
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional CSS classes to apply. |
textColor | Bulma color | 'inherit' | 'current' | — | Text color helper. |
color | 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger' | — | Text color alias: renders has-text-<color>, exactly like textColor. Not a filled variant (no .delete.is-<color> CSS exists). Prefer textColor, which takes precedence when both are set; use bgColor for a colored surface. |
bgColor | Bulma color | 'inherit' | 'current' | — | Background color helper. |
onClick | (event: React.MouseEvent<HTMLButtonElement>) => void | — | Click handler for the button. |
size | 'small' | 'medium' | 'large' | — | Size modifier for the delete button. |
ariaLabel | string | 'Close' | Accessible name for the button. An aria-label you pass takes precedence over it, unless it is empty or arrives as undefined through a spread. An empty ariaLabel falls back to the default too, so the button is never left unnamed. |
disabled | boolean | false | Whether the button is disabled (default: false). |
... | All standard <button> attributes and Bulma helper props | — | See Helper Props |
CSS & Sass Variables
Bulma declares these variables on the .delete element itself, through a mixin its rule includes, and declares some of them again on .delete.is-small, .delete.is-medium and .delete.is-large. A value set on an ancestor, on :root or through Theme never reaches them, because the element's own declaration wins. Set them on the element: with the style prop, or with a class via className whose rule loads after the library styles and, with one of those modifiers on, out-ranks the modifier's rule.
| CSS Variable | Sass Variable | Default |
|---|---|---|
--bulma-delete-dimensions | — | 1.25rem |
--bulma-delete-background-l | — | 0% |
--bulma-delete-background-alpha | — | 0.5 |
--bulma-delete-color | — | var(--bulma-white) |