> For the complete documentation index, see [llms.txt](https://2600hz.gitbook.io/sds/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://2600hz.gitbook.io/sds/sds-components/simple-components/button-group/code.md).

# Code

## Props - Single Selection

<table><thead><tr><th width="212">Props</th><th width="399.66666666666663">Data Type</th><th>Required</th></tr></thead><tbody><tr><td>children</td><td><a href="/pages/-Mftbu30T-b_0tQjWR9R">Button Component</a></td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td>className</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr></tbody></table>

### How It Works

Button Group Component works as a wrapper where developers can insert all the Button components required, changing their appearance to give them a more consistent composition. Beside that, Button Group Component has its own styles to work together the select prop of the Base Button Component.

This means, developers are going to be able to manage their states based on individual buttons events, having a simpler and a more complete control on the actions to be exectued.

{% hint style="info" %}
Button Group Component styles only are optimized to work with the Button Component in its Base type, any other Button type is going to require custom css styles from the developers.
{% endhint %}

### Example

```tsx
import React from 'react';
import {Button, ButtonGroup} from '@2600hz/sds-react-components';

const Example = ()=>{
    const [selection, setSelection] = useState({
      button1: false,
      button2: false,
      button3: false
    });
  
    const updateSelection = (e: any) => {
      const selectedButton = e.target.getAttribute('custom-data');
  
      setSelection((prevState: any) => ({
        ...prevState,
        [selectedButton]: !prevState[selectedButton]
      }));
    };
  
    return (
      <ButtonGroup>
        <Button
          customData="button1"
          selected={selection.button1}
          onClick={updateSelection}
        >
          Button 1
        </Button>
        <Button
          customData="button2"
          selected={selection.button2}
          onClick={updateSelection}
        >
          Button 2
        </Button>
        <Button
          customData="button3"
          selected={selection.button3}
          onClick={updateSelection}
        >
          Button 3
        </Button>
      </ButtonGroup>
    );
}
```

## Components Dependency

For this component elaboration there were used the following internal components:

* [Button](/sds/sds-components/simple-components/button.md)

## Live Demo

For detailed code usage documentation, see the Storybooks for each framework below.

### React

{% embed url="<https://sipster-react-component-storybook.netlify.app/?path=%2Fstory%2Fgeneral-components-button-group--single-selection-button-group>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://2600hz.gitbook.io/sds/sds-components/simple-components/button-group/code.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
