Skip to content

Commit 63c3be1

Browse files
dauriamarcospike-rabbit
authored andcommitted
docs(button-group): add button group code section
1 parent 2e7a2dc commit 63c3be1

File tree

6 files changed

+127
-145
lines changed

6 files changed

+127
-145
lines changed

docs/components/buttons-menus/button-group.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,124 @@ The button group component is inherently horizontal and cannot be wrapped or sta
9898
Alternatively, actions can be collapsed under a menu or replaced with a [select](../forms-inputs/select.md),
9999
[radio](../forms-inputs/radio.md), or [checkboxes](../forms-inputs/checkbox.md) component,
100100
depending on the interaction type.
101+
102+
## Code ---
103+
104+
Button groups are created using CSS classes. The button group component is CSS-only and does not require any Angular components.
105+
106+
### Usage
107+
108+
Wrap buttons in a `btn-group` container with the appropriate `role` and `aria-label` attributes for accessibility.
109+
110+
```html
111+
<div class="btn-group" role="group" aria-label="Basic example">
112+
<button type="button" class="btn btn-secondary">Left</button>
113+
<button type="button" class="btn btn-secondary">Middle</button>
114+
<button type="button" class="btn btn-secondary">Right</button>
115+
</div>
116+
```
117+
118+
### Button group sizes
119+
120+
Button groups support three sizes: small (`btn-sm`), default, and large (`btn-lg`).
121+
122+
```html
123+
<!-- Large group -->
124+
<div class="btn-group" role="group" aria-label="Large group">
125+
<button type="button" class="btn btn-lg btn-secondary">Large</button>
126+
<button type="button" class="btn btn-lg btn-secondary">Group</button>
127+
</div>
128+
129+
<!-- Default group -->
130+
<div class="btn-group" role="group" aria-label="Default group">
131+
<button type="button" class="btn btn-secondary">Default</button>
132+
<button type="button" class="btn btn-secondary">Group</button>
133+
</div>
134+
135+
<!-- Small group -->
136+
<div class="btn-group" role="group" aria-label="Small group">
137+
<button type="button" class="btn btn-sm btn-secondary">Small</button>
138+
<button type="button" class="btn btn-sm btn-secondary">Group</button>
139+
</div>
140+
```
141+
142+
### Icon-only buttons
143+
144+
For icon-only button groups, use the `btn-icon` class along with appropriate `aria-label` attributes.
145+
146+
```html
147+
<div class="btn-group" role="group" aria-label="Icon button group">
148+
<button type="button" class="btn btn-icon btn-secondary" aria-label="Edit">
149+
<i class="icon element-edit"></i>
150+
</button>
151+
<button type="button" class="btn btn-icon btn-secondary" aria-label="Copy">
152+
<i class="icon element-copy"></i>
153+
</button>
154+
<button type="button" class="btn btn-icon btn-secondary" aria-label="Delete">
155+
<i class="icon element-delete"></i>
156+
</button>
157+
</div>
158+
```
159+
160+
### Action button group example
161+
162+
<si-docs-component example="buttons/button-groups" height="400"></si-docs-component>
163+
164+
### Split button
165+
166+
A split button combines a primary action with a dropdown menu of related options.
167+
168+
```html
169+
<div class="btn-group" role="group" aria-label="Split button">
170+
<button type="button" class="btn btn-primary">
171+
<i class="icon element-download"></i>
172+
Download
173+
</button>
174+
<button
175+
type="button"
176+
class="btn btn-primary btn-icon dropdown-toggle"
177+
aria-label="Dropdown toggle"
178+
[cdkMenuTriggerFor]="dropdownMenu"
179+
>
180+
<i class="dropdown-caret icon element-down-2"></i>
181+
</button>
182+
</div>
183+
```
184+
185+
<si-docs-component example="buttons/split-button" height="300"></si-docs-component>
186+
187+
### Selection button
188+
189+
For selection-based button groups that represent different states or views, use radio buttons or checkboxes with button styling.
190+
191+
**Single-select:**
192+
193+
```html
194+
<div class="btn-group" role="group" aria-label="View selection">
195+
<input type="radio" class="btn-check" name="view" id="view-all" checked />
196+
<label class="btn" for="view-all">All</label>
197+
198+
<input type="radio" class="btn-check" name="view" id="view-read" />
199+
<label class="btn" for="view-read">Read</label>
200+
201+
<input type="radio" class="btn-check" name="view" id="view-unread" />
202+
<label class="btn" for="view-unread">Unread</label>
203+
</div>
204+
```
205+
206+
**Multi-select:**
207+
208+
```html
209+
<div class="btn-group" role="group" aria-label="Filter options">
210+
<input type="checkbox" class="btn-check" id="filter-temp" />
211+
<label class="btn" for="filter-temp">Temperature</label>
212+
213+
<input type="checkbox" class="btn-check" id="filter-pressure" />
214+
<label class="btn" for="filter-pressure">Pressure</label>
215+
216+
<input type="checkbox" class="btn-check" id="filter-voltage" />
217+
<label class="btn" for="filter-voltage">Voltage</label>
218+
</div>
219+
```
220+
221+
<si-docs-component example="buttons/selection-buttons" height="350"></si-docs-component>

docs/components/buttons-menus/segmented-button.md

Lines changed: 0 additions & 95 deletions
This file was deleted.

docs/components/buttons-menus/split-button.md

Lines changed: 0 additions & 40 deletions
This file was deleted.

docs/components/index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,13 @@ documentation.
109109

110110
- [Scatter Chart](charts/scatter-chart.md)
111111
- [Search Bar](sorting-filtering/search-bar.md)
112-
- [Segmented Button](buttons-menus/segmented-button.md)
113112
- [Select](forms-inputs/select.md)
114113
- [Side Panel](layout-navigation/side-panel.md)
115114
- [Skeleton](progress-indication/skeleton.md)
116115
- [Slider](forms-inputs/slider.md)
117116
- [Sort Bar](sorting-filtering/sort-bar.md)
118117
- [Spinner](progress-indication/spinner.md)
119118
- [Split](layout-navigation/split.md)
120-
- [Split buttons](buttons-menus/split-button.md)
121119
- [Status Bar](status-notifications/status-bar.md)
122120
- [Status Counter](status-notifications/status-counter.md)
123121
- [Status Toggle](status-notifications/status-toggle.md)

mkdocs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ nav:
5454
- Buttons & menus:
5555
- Buttons: 'components/buttons-menus/buttons.md'
5656
- Button Group: 'components/buttons-menus/button-group.md'
57-
- Segmented Button: 'components/buttons-menus/segmented-button.md'
58-
- Split buttons: 'components/buttons-menus/split-button.md'
5957
- Content Action Bar: 'components/buttons-menus/content-actions.md'
6058
- Dropdowns: 'components/buttons-menus/dropdowns.md'
6159
- Help Button: 'components/buttons-menus/help-button.md'

src/app/examples/buttons/button-groups.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080

8181
<h4 class="mb-4">Sizing</h4>
8282
<div class="d-flex flex-wrap align-items-center gap-4 mb-6">
83-
<div class="btn-group btn-group-lg" role="group" aria-label="Large group">
83+
<div class="btn-group" role="group" aria-label="Large group">
8484
<button type="button" class="btn btn-lg btn-primary">Large</button>
8585
<button type="button" class="btn btn-lg btn-primary">Group</button>
8686
<button type="button" class="btn btn-lg btn-primary">Size</button>
@@ -92,15 +92,15 @@ <h4 class="mb-4">Sizing</h4>
9292
<button type="button" class="btn btn-primary">Size</button>
9393
</div>
9494

95-
<div class="btn-group btn-group-sm" role="group" aria-label="Small group">
95+
<div class="btn-group" role="group" aria-label="Small group">
9696
<button type="button" class="btn btn-sm btn-primary">Small</button>
9797
<button type="button" class="btn btn-sm btn-primary">Group</button>
9898
<button type="button" class="btn btn-sm btn-primary">Size</button>
9999
</div>
100100
</div>
101101

102102
<div class="d-flex flex-wrap align-items-center gap-4 mb-6">
103-
<div class="btn-group btn-group-lg" role="group" aria-label="Large group">
103+
<div class="btn-group" role="group" aria-label="Large group">
104104
<button type="button" class="btn btn-lg btn-secondary">Large</button>
105105
<button type="button" class="btn btn-lg btn-secondary">Group</button>
106106
<button type="button" class="btn btn-lg btn-secondary">Size</button>
@@ -112,15 +112,15 @@ <h4 class="mb-4">Sizing</h4>
112112
<button type="button" class="btn btn-secondary">Size</button>
113113
</div>
114114

115-
<div class="btn-group btn-group-sm" role="group" aria-label="Small group">
115+
<div class="btn-group" role="group" aria-label="Small group">
116116
<button type="button" class="btn btn-sm btn-secondary">Small</button>
117117
<button type="button" class="btn btn-sm btn-secondary">Group</button>
118118
<button type="button" class="btn btn-sm btn-secondary">Size</button>
119119
</div>
120120
</div>
121121

122122
<div class="d-flex flex-wrap align-items-center gap-4 mb-6">
123-
<div class="btn-group btn-group-lg" role="group" aria-label="Large group">
123+
<div class="btn-group" role="group" aria-label="Large group">
124124
<button type="button" class="btn btn-lg btn-tertiary">Large</button>
125125
<button type="button" class="btn btn-lg btn-tertiary">Group</button>
126126
<button type="button" class="btn btn-lg btn-tertiary">Size</button>
@@ -132,7 +132,7 @@ <h4 class="mb-4">Sizing</h4>
132132
<button type="button" class="btn btn-tertiary">Size</button>
133133
</div>
134134

135-
<div class="btn-group btn-group-sm" role="group" aria-label="Small group">
135+
<div class="btn-group" role="group" aria-label="Small group">
136136
<button type="button" class="btn btn-sm btn-tertiary">Small</button>
137137
<button type="button" class="btn btn-sm btn-tertiary">Group</button>
138138
<button type="button" class="btn btn-sm btn-tertiary">Size</button>

0 commit comments

Comments
 (0)