Skip to content

Split button component - #1463

Open
bjarnef wants to merge 8 commits into
umbraco:mainfrom
bjarnef:feature/split-button
Open

bjarnef wants to merge 8 commits into
umbraco:mainfrom
bjarnef:feature/split-button

Conversation

@bjarnef

@bjarnef bjarnef commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Based on discussion: #1133

Split Button seems to be a common concept throughout UI/UX, where the button has an action + additional actions via dropdown.
https://www.nngroup.com/articles/split-buttons/
https://web.dev/articles/building/a-split-button-component

Part of it based on umb-dropdown here, but I think the dropdown should act on a button/toggle next to a primary button as examples above.
https://github.com/umbraco/Umbraco-CMS/blob/45b4b2a132f92ad034d33e5ccc413415105b4c33/src/Umbraco.Web.UI.Client/src/packages/core/components/dropdown/dropdown.element.ts

Currently it has 1px gap, but there may be a better way to add a border/separator, so it inherits same color as text color and not rely on background color in user interface.

Using two button components ensure we can navigate these via keyboard.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Motivation and context

I think it would be useful in many parts of back office UI, e.g. "Save & Publish" may be primary actions, while popup/dropdown button shows more actions.

Also in collections with one or more actions. Either a regular button if only a single action of just render split button without expand options.

How to test?

Screenshots (if appropriate)

image

With the new rounding in UI library v2, I think the compact button looks a bit too squeezed:

image

Checklist

  • If my change requires a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

Copilot AI review requested due to automatic review settings July 29, 2026 12:51
@github-actions

Copy link
Copy Markdown

Hi there @bjarnef, thank you for this contribution! 👍

While we wait for the team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@bjarnef bjarnef changed the title Add split button component Split button component Jul 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new <uui-split-button> component to the UUI component library, including registration, implementation, Storybook story, README, and an export from the components barrel so it can be consumed via @umbraco-ui/uui/components/....

Changes:

  • Introduces the new split-button component (registration + Lit element implementation).
  • Adds Storybook documentation (story + README) and a minimal Vitest test.
  • Exposes the new component from src/components/index.ts.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/components/split-button/split-button.ts Registers <uui-split-button> and exports the element API.
src/components/split-button/split-button.element.ts Implements the split-button element (buttons + popover dropdown + styling).
src/components/split-button/split-button.story.ts Adds Storybook stories demonstrating common states.
src/components/split-button/split-button.test.ts Adds initial unit/a11y test coverage for the component.
src/components/split-button/README.md Documents basic import/usage for the new component.
src/components/index.ts Re-exports the split-button registration for library consumers.

Comment on lines +16 to +28
@property({ type: Boolean, reflect: true })
public get open() {
return this.#open;
}
public set open(value) {
this.#open = value;

if (value === true && this.popoverContainerElement) {
this.openDropdown();
} else {
this.closeDropdown();
}
}
Comment on lines +42 to +49
@property({ type: Boolean })
compact = false;

@property({ type: Boolean, reflect: true })
disabled = false;

@property({ type: Boolean, attribute: 'hide-expand' })
hideExpand = false;
Comment on lines +54 to +79
openDropdown() {
// TODO: This ignorer is just needed for JSON SCHEMA TO WORK, As its not updated with latest TS jet.
// @ts-ignore
this.popoverContainerElement?.showPopover();
this.#open = true;
}

closeDropdown() {
// TODO: This ignorer is just needed for JSON SCHEMA TO WORK, As its not updated with latest TS jet.
// @ts-ignore
this.popoverContainerElement?.hidePopover();
this.#open = false;
}

#onToggle(event: ToggleEvent) {
// TODO: This ignorer is just needed for JSON SCHEMA TO WORK, As its not updated with latest TS jet.

// @ts-ignore
this.open = event.newState === 'open';

/*if (this.open) {
this.dispatchEvent(new UmbOpenedEvent());
} else {
this.dispatchEvent(new UmbClosedEvent());
}*/
}
Comment on lines +103 to +110
html`<uui-button
.look=${this.look}
.color=${this.color}
.compact=${this.compact}
?disabled=${this.disabled}
id="dropdown-button"
popovertarget="dropdown-popover"
data-mark="open-dropdown">
Comment on lines +121 to +123
<umb-popover-layout>
<slot></slot>
</umb-popover-layout>
Comment on lines +10 to +13
/**
* @element uui-split-button
*/
export class UUISplitButtonElement extends LitElement {
Comment on lines +1 to +24
import './split-button.js';
import { html } from 'lit';
import { render } from 'vitest-browser-lit';
import { axeRun } from '../../internal/test/a11y.js';
import { UUISplitButtonElement } from './split-button.element';

describe('UUISplitButtonElement', () => {
let element: UUISplitButtonElement;

beforeEach(async () => {
element = render(
html`<uui-split-button></uui-split-button>`,
).container.querySelector('uui-split-button')!;
await element.updateComplete;
});

it('is defined with its own instance', () => {
expect(element).toBeInstanceOf(UUISplitButtonElement);
});

it('passes the a11y audit', async () => {
expect(await axeRun(element)).toHaveNoViolations();
});
});
bjarnef and others added 3 commits July 29, 2026 15:41
@sonarqubecloud

Copy link
Copy Markdown

@iOvergaard iOvergaard added feature Something we are looking to build community/pr labels Oct 5, 2026
@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community/pr feature Something we are looking to build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants