Repository navigation
Extract Toast::CloseButton component and add button slot - #144
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Flat aria-label options produce duplicate attributes rather than reliably overriding the default accessible label.
1 open issue
What changed in this PR
This PR lets applications customize the Toast close button without overriding its template, using the nested options pattern already used by InputField.
Changes:
- Adds
close_button: {options: {...}}, merging HTML options with defaults and appending custom classes. - Renders the button through Rails’ tag helper.
- Adds customization tests and documents the new option.
| File | Description |
|---|---|
| test/components/flowbite/toast_test.rb | Tests custom classes, data attributes, and nested ARIA labels. |
| CHANGELOG.md | Documents close-button HTML options. |
| app/components/flowbite/toast/toast.html.erb | Renders the close button with merged options. |
| app/components/flowbite/toast.rb | Adds close-button configuration, default classes, and option merging. |
Review effort: Balanced
RasmusDWN
force-pushed
the
close-button-options
branch
from
October 23, 2026 11:27
28edb92 to
10d74b5
Compare
koppen
requested changes
Oct 23, 2026
| # @see https://flowbite.com/docs/components/toast/ | ||
| # @lookbook_embed ToastPreview | ||
| class Toast < ViewComponent::Base | ||
| renders_one :close_button |
Member
There was a problem hiding this comment.
Given that we don't really know what the button is used for (since we aren't the ones adding behavior to it), perhaps the slot should just be called button? The default button could still be a CloseButton, though.
Contributor
Author
There was a problem hiding this comment.
I have renamed the slot and argument to button, so now it's more generic. CloseButton is still the default.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Flowbite::Toastrenders a close button but gives no way to customize it, so apps can't wire up dismissal (or anything else) without overriding the template.This extracts the button into a
Flowbite::Toast::CloseButtoncomponent and adds abuttonslot, following the patternCarduses for its title:Toast::CloseButtonholds the button's classes,type,aria-labeland icon. Options passed to it are merged over the defaults, likeCard::Title.Toastgetsrenders_one :button. When the slot isn't used, it falls back todefault_button, rendered with the options frombutton: {options: {...}}.Passing options to the default button:
Rendering your own button: