Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Actions & Selection

Button Group

Groups related actions with shared borders and focus rings; nest groups for spacing; pair with Input, InputGroup, Dropdown, Select, and Popover (shadcn Button Group pattern). Make the next action easy to recognize. Use visual emphasis deliberately and distinguish an action from a persistent selection or a navigation link. Import it from @/components/kamod-ui/button-group.

Source · Design reference · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Import ButtonGroup, ButtonGroupSeparator, and ButtonGroupText from @/components/kamod-ui/button-group.

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Usage

Groups related actions with shared borders and focus rings; nest groups for spacing; pair with Input, InputGroup, Dropdown, Select, and Popover (shadcn Button Group pattern).

Import SetupTypeScript
import { Button, ButtonGroup } from "@kamod-ch/ui";
Usage PatternTypeScript
<ButtonGroup>
  <Button>Button 1</Button>
  <Button>Button 2</Button>
</ButtonGroup>

Accessibility

ButtonGroup is a grouping wrapper with role="group"; it does not turn its children into a toolbar with managed arrow-key focus. Each button or link retains its own behavior and tab stop.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Component Examples & Variants

Explore Button Group in Different Contexts, from the starting pattern to the compositions below. Begin with Button Group vs Toggle Group, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

Button Group vs Toggle Group

Distinguish Actions from Selection. ButtonGroup arranges related actions; Toggle Group represents selected choices. Compare the two when designing a toolbar so pressing an action and changing a persistent selection use the appropriate primitives.

In the preview, distinguish Doing Something from Choosing a Setting. Opening a menu or submitting a form is an action; choosing alignment or an active view needs a value the rest of the interface can read.

Group Text

Label the Whole Interaction Clearly. Use ButtonGroupText for a short prefix or context label within the joined control. With asChild, it can style a Label associated with a nearby field instead of adding an unrelated text wrapper.

When it labels a form input, preserve the actual label association; visual proximity alone does not connect the text to the field for assistive technology.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Orientation

Adapt the Group to Its Available Space. Set orientation="vertical" to stack the controls and join their adjacent edges. This works for compact increase/decrease actions when the vertical arrangement clearly conveys their relationship to the same value.

Keep the order meaningful from top to bottom, use consistent sizes, and verify that the grouped border treatment still distinguishes separate actions without adding unnecessary dividers.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Size

Size the Children as a Coherent Set. Set size on each child Button to coordinate the group's density. Matching text and icon sizes keeps joined edges and heights aligned without making the parent group responsible for each action's typography.

Check the entire group with its longest label before tightening the layout, especially when the controls will appear in a responsive toolbar.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Nested

Separate Clusters inside One Tool. Nest ButtonGroup elements when one toolbar contains distinct clusters. Each inner group keeps its own joined buttons, while the outer composition leaves a deliberate gap between different sets of actions.

Keep the hierarchy shallow and leave enough space between clusters to make the distinction visible; use a toolbar label when the purpose is not obvious from the individual actions.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Separator

Divide Actions Only Where the Surface Needs It. Insert ButtonGroupSeparator between filled controls when their shared edge needs clarification. Outlined buttons already provide a boundary, so compare the result before introducing an additional line between every action.

Keep it decorative, match its orientation to the group, and avoid doubling borders when an outlined child already provides a clear boundary.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Split

Separate the Common Action from Its Alternatives. Place a main action beside a compact icon action and divide them with ButtonGroupSeparator. This split pattern makes the default operation immediately available while reserving the adjacent control for related alternatives.

Give the icon trigger a descriptive name and avoid making both halves open the same menu unless that behavior is clearly intentional.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Input

Keep Entry and Submission Together. Place Input directly beside its related button inside the group. Direct input children can grow with flex-1, leaving the action a stable width while the editable value takes the remaining space.

Supply a real label or accessible name, use the correct button type in forms, and allow the input to shrink without hiding the action.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Input Group

Compose Nested Controls without Losing Their Roles. Compose nested groups with Input Group to place addons and a voice control in one rounded bar. The example shows which boundaries belong to the field and which belong to neighboring actions.

Try the composition at its narrowest useful width and confirm that the editable value still has room. Give the voice toggle a meaningful accessible name, and keep its pressed state separate from the text input's value.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Select

Make the Selected Context Explicit. Join a currency Select, an amount input and a send action into a single task. Each control still has its own value and label, even though the shared outline presents them as one composition.

Keep validation attached to the relevant field and ensure the submit action uses the current selection rather than a separate hard-coded assumption.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Popover

Reveal Supporting Choices in Place. Attach a Popover to the trailing chevron when the secondary control needs a small panel rather than a menu. The main button remains directly available beside that configuration entry point.

Keep the trigger named, preserve focus behavior, and use Popover examples when the panel contains multiple form controls.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width
API reference

Props and Data

Configure Button Group using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props for ButtonGroup, ButtonGroupSeparator, and ButtonGroupText.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/button-group7.5 KB min · 2.4 KB gzipSignals: none

ButtonGroup

ButtonGroupProps

ButtonGroup documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildButtonGroupProps

Configure children for ButtonGroup. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>ButtonGroupProps

Configure class for ButtonGroup. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
orientation
"horizontal" | "vertical"ButtonGroupProps

Configure orientation for ButtonGroup. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"horizontal"

ButtonGroupSeparator

ButtonGroupSeparatorProps

ButtonGroupSeparator documented props
Prop / typeDescription
class
string | SignalLike<string | undefined>ButtonGroupSeparatorProps

Configure class for ButtonGroupSeparator. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
orientation
"horizontal" | "vertical"ButtonGroupSeparatorProps

Configure orientation for ButtonGroupSeparator. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"vertical"

ButtonGroupText

ButtonGroupTextProps

ButtonGroupText documented props
Prop / typeDescription
asChild
booleanButtonGroupTextProps

Configure asChild for ButtonGroupText. Compare its accepted type with the Usage Guidance before supplying a value.

Default
false
children
ComponentChild[] | ComponentChildButtonGroupTextProps

Configure children for ButtonGroupText. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>ButtonGroupTextProps

Configure class for ButtonGroupText. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

ButtonGroup Props

2 declared fields
ButtonGroupProps
Exported Source Declaration from ButtonGroup.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ButtonGroupProps before adapting it.

ButtonGroupSeparator Props

1 declared field
ButtonGroupSeparatorProps
Exported Source Declaration from ButtonGroupSeparator.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ButtonGroupSeparatorProps before adapting it.

ButtonGroupText Props

2 declared fields
ButtonGroupTextProps
Exported Source Declaration from ButtonGroupText.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ButtonGroupTextProps before adapting it.

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.