React Dropdown Button
The React Dropdown Button is a graphical user interface component that displays Dropdown Buttons with visual severity levels. It differentiates Buttons with icons and colors to denote the importance and context of the Button. It has several built-in features, such as severities, variants, icons, and a template.
Getting started
To create a new Vite project, refer to the Vite documentation. Once that Vite project is ready to run with default settings, let’s add the React Dropdown Button component to the project.
Installing Syncfusion® React packages
To use the Dropdown Button component, install the @syncfusion/react-splitbuttons package:
Adding CSS reference
Import the Dropdown Button component’s required CSS references as follows in src/App.css.
Adding Dropdown Button component
To include the Dropdown Button component in your application, import the DropDownButton from @syncfusion/react-splitbuttons package in App.tsx.
Add the Dropdown Button component in application as shown in below code example.
Run the project
To run the project, use the following command:
The following example demonstrates how to create a simple Dropdown Button component.
Disabled
The Disabled state illustrates how to render a Dropdown Button component when it should not be interactive, ensuring that users understand its deactivation through styling and functionality.
Color
The Dropdown Button component provides a variety of styles to indicate different alert levels, such as Warning, Success, Error, and Info, by utilizing the color property.
Size
Easily customize the Dropdown Button's size to match your design requirements using its built-in sizing properties.
Icons
The Dropdown Button includes an icon or image to visually represent the associated action. To add an icon to a Dropdown Button, use the icon property.
Template
The itemTemplate property in the Dropdown Button component allows for the definition of custom templates to display dropdown items. This feature is especially useful for customizing the appearance and layout of dropdown items beyond the default options provided.
Accessibility
The Dropdown Button component followed the accessibility guidelines and standards, including ADA, Section 508, WCAG 2.2 standards, and WCAG roles that are commonly used to evaluate accessibility.
The accessibility compliance for the Dropdown Button component is outlined below.
| Accessibility Criteria | Compatibility |
|---|---|
| WCAG 2.2 Support | |
| Section 508 Support | |
| Screen Reader Support | |
| Right-To-Left Support | |
| Color Contrast | |
| Mobile Device Support | |
| Keyboard Navigation Support | |
| Accessibility Validation |
- All features of the component meet the requirement.
- Some features of the component do not meet the requirement.
- The component does not meet the requirement.
WAI-ARIA attributes
The Dropdown Button component followed the WAI-ARIA patterns to meet the accessibility. The following ARIA attributes are used in the Dropdown component:
| Attributes | Purpose |
|---|---|
| role | Indicates the Dropdown component as button, Dropdown popup as menu, and the Dropdown popup action items as menuitem. |
| aria-haspopup | Indicates the availability and type of interactive Dropdown popup element. |
| aria-expanded | Indicates whether the Dropdown popup can be expanded or collapsed, as well as indicates whether its current state is expanded or collapsed. |
| aria-disabled | Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable. |
Keyboard interaction
The Dropdown Button component followed the keyboard interaction guideline, making it easy for people who use assistive technologies (AT) and those who completely rely on keyboard navigation. The following keyboard shortcuts are supported by the Dropdown component.
| Windows | Mac | To do this |
|---|---|---|
| Space , Enter | Space , Enter | Opens and closes the popup. |
| Esc | Esc | Closes the opened popup. |
| ↑ | ↑ | Navigates up or to the previous action item. |
| ↓ | ↓ | Navigates down or to the Next action item. |