No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

The component failed to render properly, likely due to a configuration issue in Storybook. Here are some common causes and how you can address them:

  1. Missing Context/Providers: You can use decorators to supply specific contexts or providers, which are sometimes necessary for components to render correctly. For detailed instructions on using decorators, please visit the Decorators documentation.
  2. Misconfigured Webpack or Vite: Verify that Storybook picks up all necessary settings for loaders, plugins, and other relevant parameters. You can find step-by-step guides for configuring Webpack or Vite with Storybook.
  3. Missing Environment Variables: Your Storybook may require specific environment variables to function as intended. You can set up custom environment variables as outlined in the Environment Variables documentation.

This is a pre-release version and is not production ready. For new and ongoing projects, please refer to the latest Design System version.

Group a series of buttons together on a single line.
<div class="btn-group" role="group" aria-label="Button group example"> <button type="button" class="btn btn-md btn-secondary">Left</button> <button type="button" class="btn btn-md btn-secondary">Middle</button> <button type="button" class="btn btn-md btn-secondary">Right</button> </div>
NameDescriptionDefaultControl
General
Size
Sets the size of the button group.
string
-
Variant
Defined the semantic elements used as button within the group.
string
-
Content
First Label
Defines the label of the first button.
string
-
Second Label
Defines the label of the second button.
string
-
Third Label
Defines the label of the third button.
string
-

Make sure the @swisspost/design-system-styles package is already present in your project or follow the installation guidelines.

To import all Design System styles:

@use '@swisspost/design-system-styles/post-compact.scss';

To import only the styles required for this component:

@use '@swisspost/design-system-styles/basics.scss'; @use '@swisspost/design-system-styles/components/button-group.scss';

The following examples show the different characteristics of the component. These can differ in the type of visualization, the html structure, as well as when, how and why they are displayed.

You can change the size of buttons belonging to a group using button-sizing classes: .btn-sm, .btn-md and .btn-lg. Just be sure to apply the same class to all buttons contained in the group.

Any HTML element that can be styled as a button can potentially be used in a button group. It is also possible to use checkable inputs:

  • Checkboxes: this allows all buttons in the group to be selected or deselected individually,
  • Radio buttons: in this case all the buttons are linked and only one of them can be selected at a time.