# Blazor SplitButton Overview

The <a href = "https://www.telerik.com/blazor-ui/split-button" target="_blank">SplitButton for Blazor</a> is a combination of a button and a dropdown. It provides a collection of related user actions in a compact interface. The SplitButton has one primary clickable action, which is always visible, and a list of secondary actions that are displayed in a dropdown when the user clicks on the arrow.

## SplitButton vs. DropDownButton

The DropDownButton and SplitButton components are similar. They both consist of a primary button and a dropdown element that holds additional action items. The major difference is the purpose of the primary button.

* [DropDownButton](https://www.telerik.com/blazor-ui/documentation/components/dropdownbutton/overview)—The main purpose of the primary button is to open the popup with additional actions. The primary button exposes a separate [`OnClick` event](https://www.telerik.com/blazor-ui/documentation/components/dropdownbutton/events), which can invoke a dedicated action. Clicking on the DropDownButton always opens the dropdown.

* [SplitButton](https://www.telerik.com/blazor-ui/documentation/components/splitbutton/overview)—The main element contains a primary button and a separate button for opening the dropdown. The purpose of the primary button is to [invoke a standalone action](https://www.telerik.com/blazor-ui/documentation/components/splitbutton/events#onclick). Clicking on it does not open the dropdown. To open the popup with the additional actions, the user has to click the dedicated button with `caret-alt-down` icon. It is possible to [switch the primary and dropdown actions programmatically](https://www.telerik.com/blazor-ui/documentation/knowledge-base/splitbutton-dynamic-primary-change-onclick).

## Creating Blazor SplitButton

1. Add a `<TelerikSplitButton>` tag.
2. Define the primary action in a child `<SplitButtonContent>` tag. Its content can be plain text, HTML or even another component.
3. Set the `OnClick` parameter of the `<TelerikSplitButton>` tag. This will be the event handler for the primary action.
4. Add a child `<SplitButtonItems>` tag. Insert some `<SplitButtonItem>` tags inside it.
5. Each `<SplitButtonItem>` tag should have some content and an `OnClick` handler.

> caption Basic SplitButton

<demo metaUrl="client/splitbutton/overview/example-2/" height="320"></demo>

## Icons

The primary SplitButton action and each secondary item in the dropdown can [display a font icon or an image](https://www.telerik.com/blazor-ui/documentation/components/splitbutton/icons) for better looks and user experience.

## Appearance

The SplitButton provides a [variety of settings to control its visual appearance](https://www.telerik.com/blazor-ui/documentation/components/splitbutton/appearance), for example the colors, borders, and size. This spares the need to use custom CSS code.

> tip To learn more about the appearance, anatomy, and accessibility of the SplitButton, visit the [Progress Design System Kit documentation](https://www.telerik.com/design-system/docs/components/splitbutton/)—an information portal offering rich component usage guidelines, descriptions of the available style variables, and globalization support details.

## Events

Each SplitButton action [fires a separate `OnClick` event](https://www.telerik.com/blazor-ui/documentation/components/splitbutton/events), so that the application can react to user behavior.

## SplitButton Parameters

The following table lists the SplitButton parameters, except those related to [built-in styling](https://www.telerik.com/blazor-ui/documentation/components/splitbutton/appearance) and [icons](https://www.telerik.com/blazor-ui/documentation/components/splitbutton/icons). Also check the [SplitButton API Reference](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.teleriksplitbutton) for a full list of properties, methods and events.

<style>
    .article table {
        table-layout: auto;
        word-break: normal;
    }
</style>

| Parameter   | Type and Default Value | Description                                                                                                                                                                                                                                                                                                                                                                                                               |
| ----------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AriaLabel` | `string`               | Sets the `aria-label` attribute of the primary action element, which is `<button class="k-button">`.                                                                                                                                                                                                                                                                                                                      |
| `Class`     | `string`               | Renders a custom CSS class to the main component element, which is `<div class="k-split-button">`. Use it to [override the theme styles](https://www.telerik.com/blazor-ui/documentation/styling-and-themes/override-theme-styles) to obtain a specific appearance, if none of the [SplitButton appearance settings](https://www.telerik.com/blazor-ui/documentation/components/splitbutton/appearance) can achieve this. |
| `Enabled`   | `bool`<br />(`true`)   | Enables or disables the component.                                                                                                                                                                                                                                                                                                                                                                                        |
| `Id`        | `string`               | Sets the `id` attribute of the primary action element (`<button>`).                                                                                                                                                                                                                                                                                                                                                       |
| `TabIndex`  | `int`                  | Sets the `tabindex` attribute of the primary action element.                                                                                                                                                                                                                                                                                                                                                              |
| `Title`     | `string`               | Sets the `title` attribute of the primary action element.                                                                                                                                                                                                                                                                                                                                                                 |

### Popup Settings

The SplitButton exposes configuration settings for its dropdown (popup). The parameters should be set in a `<SplitButtonPopupSettings>` tag, which should be placed inside a `<SplitButtonSettings>` tag like this:

```HTML.skip-repl
<TelerikSplitButton>
    <SplitButtonSettings>
        <SplitButtonPopupSettings Height="150px" />
    </SplitButtonSettings>
</TelerikSplitButton>
```

| Parameter           | Type and Default Value     | Description                                                                                                                                         |
| ------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AnimationDuration` | `int` <br /> (`300`)       | Sets the dropdown animation duration in milliseconds.                                                                                               |
| `Class`             | `string`                   | Renders a custom CSS class to the dropdown container, which is `<div class="k-animation-container">`.                                               |
| `Height`            | `string` <br /> (`"auto"`) | The dropdown height. If the items cannot fit, a vertical scrollbar will appear. If not set, the dropdown will expand, based on the number of items. |
| `MaxHeight`         | `string`                   | The maximum dropdown height, if an explicit height is not set.                                                                                      |
| `MinHeight`         | `string`                   | The minimum dropdown height, if an explicit height is not set.                                                                                      |
| `Width`             | `string`                   | The dropdown width. If not set, the dropdown will expand, based on the length of its items.                                                         |
| `MaxWidth`          | `string`                   | The maximum dropdown width, if an explicit width is not set. If there is a longer item, a horizontal scrollbar will show.                           |
| `MinWidth`          | `string`                   | The minimum dropdown width, if an explicit width is not set.                                                                                        |

> tip As in standard CSS, the *min* and *max* settings take precedence over *width* and *height*.

### Item Settings

The following table lists the `SplitButtonItem` parameters, except those related to [icons](https://www.telerik.com/blazor-ui/documentation/components/splitbutton/icons).

| Parameter | Type and Default Value | Description                                                                                            |
| --------- | ---------------------- | ------------------------------------------------------------------------------------------------------ |
| `Class`   | `string`               | Renders a custom CSS class to the dropdown item's element, which is `<li class="k-item k-menu-item">`. |
| `Enabled` | `bool`<br />(`true`)   | Enables or disables the item.                                                                          |

## SplitButton Reference and Methods

The [SplitButton exposes methods](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.teleriksplitbutton#methods) for programmatic operation. To use them, capture the component instance with the `@ref` attribute. The `OnAfterRender` and `OnAfterRenderAsync` life-cycle events are the earliest time when the component instance is available. Also see how to [focus the SplitButton on page load](https://www.telerik.com/blazor-ui/documentation/knowledge-base/inputs-set-focus#focus-on-page-load).

> caption Get a reference to the SplitButton and execute methods

<demo metaUrl="client/splitbutton/overview/example-1/" height="420"></demo>

## Next Steps

* [Handle SplitButton Events](https://www.telerik.com/blazor-ui/documentation/components/splitbutton/events)
* [Add SplitButton Icons](https://www.telerik.com/blazor-ui/documentation/components/splitbutton/icons)
* [Configure the SplitButton appearance](https://www.telerik.com/blazor-ui/documentation/components/splitbutton/appearance)

## See Also

* [SplitButton API](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.teleriksplitbutton)
* [Live Demo: SplitButton](https://demos.telerik.com/blazor-ui/splitbutton/overview)
* [KB: Change Primary SplitButton Action on Click](https://www.telerik.com/blazor-ui/documentation/knowledge-base/splitbutton-dynamic-primary-change-onclick)
