-
Notifications
You must be signed in to change notification settings - Fork 81
Added new kb article dropdownbutton-add-separator-between-items #2834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ntacheva
merged 8 commits into
master
from
new-kb-dropdownbutton-add-separator-between-items-a8c58a4aa4ee44c9860e1d1bdd021cae
Mar 19, 2025
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8f8a61c
Added new kb article dropdownbutton-add-separator-between-items
d89ef5f
Update knowledge-base/dropdownbutton-add-separator-between-items.md
ntacheva 1bee888
Update knowledge-base/dropdownbutton-add-separator-between-items.md
ntacheva 2fc3e68
Update knowledge-base/dropdownbutton-add-separator-between-items.md
ntacheva 99553f9
Update knowledge-base/dropdownbutton-add-separator-between-items.md
ntacheva dbd3a6b
Update knowledge-base/dropdownbutton-add-separator-between-items.md
ntacheva 9238605
Update knowledge-base/dropdownbutton-add-separator-between-items.md
ntacheva 0bc8320
Update knowledge-base/dropdownbutton-add-separator-between-items.md
ntacheva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
knowledge-base/dropdownbutton-add-separator-between-items.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| --- | ||
| title: Adding a Separator Between Items in a DropDownButton for Blazor | ||
| description: Learn how to add a separator between the items in a DropDownButton by utilizing custom styling in a Blazor application. | ||
| type: how-to | ||
| page_title: How to Implement Item Separators in a Telerik Blazor DropDownButton | ||
| slug: dropdownbutton-kb-add-separator-between-items | ||
| tags: dropdownbutton, blazor, item separator, custom styling | ||
| res_type: kb | ||
| ticketid: 1680307 | ||
| --- | ||
|
|
||
| ## Environment | ||
| <table> | ||
| <tbody> | ||
| <tr> | ||
| <td>Product</td> | ||
| <td>DropDownButton for Blazor</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| ## Description | ||
|
|
||
| I want to visually separate the items in a [DropDownButton](slug:dropdownbutton-overview) to enhance the UI and improve user experience. How to add a separator (divider) between the items? | ||
|
|
||
| ## Solution | ||
|
|
||
| The DropDownButton does not have a concept for a "separator" item (similar to the [ContextMenu](slug:contextmenu-data-binding-overview), for example). However, the DropDownButton uses a declarative approach for its items, so you can add any desired item. | ||
|
|
||
| The specific is that the content you declare in the DropDownButtonItem will be rendered inside the <span class="k-menu-link-text"> which is narrower and thus your custom separator will not cover the whole width of the popup. This article demonstrates how to achieve a similar effect by utilizing custom styling. | ||
ntacheva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| To create a visual separator between items in a DropDownButton, apply a custom class to the item that precedes the separator and style its bottom border. This approach allows you to simulate a separator without the need for a dedicated separator item. The custom class can be applied directly in the item declarations in your Blazor component. | ||
|
|
||
| >caption Add separator between DropDownButton items | ||
|
|
||
| ````RAZOR | ||
| <style> | ||
| .item-with-separator { | ||
| border-bottom: 1px solid #e5e5e5; | ||
ntacheva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| </style> | ||
|
|
||
| <TelerikDropDownButton Icon="@SvgIcon.Share" OnClick="@(()=>OnItemClick("Primary"))"> | ||
ntacheva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <DropDownButtonContent>Share</DropDownButtonContent> | ||
|
|
||
| <DropDownButtonItems> | ||
| <DropDownButtonItem Icon="@SvgIcon.Facebook" OnClick="@(()=>OnItemClick("Facebook"))">Facebook</DropDownButtonItem> | ||
| <DropDownButtonItem Icon="@SvgIcon.Twitter" OnClick="@(()=>OnItemClick("Twitter"))">Twitter</DropDownButtonItem> | ||
| <DropDownButtonItem Icon="@SvgIcon.Linkedin" OnClick="@(()=>OnItemClick("Linkedin"))" Class="item-with-separator">Linkedin</DropDownButtonItem> | ||
| <DropDownButtonItem OnClick="@(()=>OnItemClick("Reddit"))">Other</DropDownButtonItem> | ||
ntacheva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </DropDownButtonItems> | ||
|
|
||
| </TelerikDropDownButton> | ||
|
|
||
| @code { | ||
| private void OnItemClick(string item) | ||
| { | ||
| Console.WriteLine($"User clicked {item} option."); | ||
| } | ||
| } | ||
ntacheva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ```` | ||
|
|
||
| ## See Also | ||
|
|
||
| - [DropDownButton Overview](slug:dropdownbutton-overview) | ||
| - [Customizing the Appearance of Telerik UI for Blazor Components](slug:themes-override) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.