From f391488aeff265cf8baa1bdaa3e998794cd14acc Mon Sep 17 00:00:00 2001 From: Arthurk12 Date: Wed, 11 Nov 2026 11:54:11 -0300 Subject: [PATCH 1/3] feat(BBButton): add pressed prop BBButton has no selected state, so a toggle button, or a group where one option is picked, has to be painted by the consumer. The poll panel's response-type picker switches variants and repaints both states with eight !important declarations, because the library's hover rule outranks any ordinary override, and screen readers hear plain buttons with no selection. Add a `pressed` prop. When it is set, the button renders `aria-pressed`; when it is true, the button gets a fill that holds through hover and active. The fill depends on `color` only, so a pressed button reads as selected next to any variant, and the colors live in a table in constants.ts for the design team to refine. A pressed button that is also disabled fades its fill instead of turning grey, so a disabled group still shows which option is selected. Forwarding `aria-pressed` alone was considered: it fixes the accessibility gap but leaves the style overrides in place. Closes #107 --- src/components/Button/README.md | 20 +++++++ src/components/Button/component.stories.tsx | 58 ++++++++++++++++++++- src/components/Button/component.tsx | 6 +++ src/components/Button/constants.ts | 25 ++++++++- src/components/Button/styles.ts | 31 ++++++++++- src/components/Button/type.ts | 14 +++++ 6 files changed, 150 insertions(+), 4 deletions(-) diff --git a/src/components/Button/README.md b/src/components/Button/README.md index 674953b..7eddfd2 100644 --- a/src/components/Button/README.md +++ b/src/components/Button/README.md @@ -71,6 +71,25 @@ import { BBButton } from 'bbb-ui-components-react'; (console.log('clicked'))}/> ``` +### Toggle Button + +Set `pressed` to make the button a toggle. It renders `aria-pressed`, and while `true` the button keeps a selected fill through hover and press. Leave it unset for a plain button. For a set of options where exactly one is selected, use [`BBBSegmentedControl`](../SegmentedControl/README.md). + +```jsx +import { BBButton } from 'bbb-ui-components-react'; +import { MdMic, MdMicOff } from 'react-icons/md'; + +const [muted, setMuted] = useState(false); + + : } + onClick={() => setMuted(!muted)} +/> +``` + ### Long Labels `labelOverflow` sets what happens when the label doesn't fit the button's available width, for example a `fullWidth` button in a narrow container or a row of equal-width buttons. It has no visible effect while the label fits. @@ -124,6 +143,7 @@ const FooterButton = styled(BBButton)` | `layout` | `keyof typeof LAYOUTS` | `'default'` | The layout of the button. | | `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | The native `type` attribute of the `