Skip to main content

ButtonGroup

The ButtonGroup component is used to group buttons together and apply specified Button properties unilateraly.

Import

// with @dhl-official/react-library:
import { DhlButtonGroup } from "@dhl-official/react-library"
// with @dhl-official/ui-libraries/react-library:
import { DhlButtonGroup } from "@dhl-official/ui-libraries/react-library"

Usage

The ButtonGroup component acts as the parent of its respective Button children. Buttons within a ButtonGroup will inherit the

  • size
  • variant
  • isDisabled
  • props from the ButtonGroup. The children Buttons override said props if specified within the scope of the Button.

Code


<DhlButtonGroup>
<DhlButton clickEvent={() => {}} variant="DHL_BUTTON.VARIANT.PRIMARY">Submit</DhlButton>
<DhlButton clickEvent={() => {}} variant="DHL_BUTTON.VARIANT.OUTLINE">Clear</DhlButton>
</DhlButtonGroup>

Changelog

v2.4.1-monorepo.8

Breaking changes
  • Deprecating isBlock property.
  • Add isFullWidth property - sets the ButtonGroup container to 100% width of the parent container.

Interactive Demo

Readme

Properties

PropertyAttributeDescriptionTypeDefault
dataAriaLabeldata-aria-labelAn optional prop defining the text read by the screen reader to represent the component; use this if you need different text to be read from label.stringundefined
dataClassNamedata-class-nameAn optional class name prop for the component.stringundefined
dataIddata-idAn optional prop. Gives a valid HTML ID attribute value for the component.stringdhl-button-group-${getRandomString()}
dataTestiddata-testidAn optional prop. The test id attached to the component as a data-testid attribute.stringundefined
isBlockis-block[DEPRECATED] An optional prop that sets whether the component inherits the width of it's container. Any Button which directly specifies their isBlock prop will get overridden by the value of the same named prop of this component.

booleanfalse
isDisabledis-disabledAn optional flag to define if the component is disabled. Any Button which directly specifies their isDisabled prop will override the disabled state set by ButtonGroup.booleanfalse
isFullWidthis-full-widthAn optional prop that sets the component to 100% width of it's parent container. Any Button which directly specifies their isFullWidth prop will get it overridden by the value of the same named prop of this component.booleanfalse
orientationorientationAn optional orientation prop for the ButtonGroup component."horizontal" \| "vertical"DHL_BUTTON_GROUP.ORIENTATION.HORIZONTAL
sizesizeAn optional size prop for the component. Any Button which directly specifies their size prop will be overridden by the value of the size prop of this component."md" \| "sm" \| "xs"DHL_BUTTON_GROUP.SIZE.MD
variantvariantAn optional prop to select a component design variant for all Buttons within the ButtonGroup. Any Button which directly specifies their variant prop will override the variant set by ButtonGroup."outline" \| "primary" \| "text"DHL_BUTTON_GROUP.VARIANT.PRIMARY

Slots

SlotDescription
"unnamed"unnamed children slot intended for multiple DhlButton components

Built by DHL User Interface Library Team!