npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xsolla/xui-toggle-button-group

v0.173.2

Published

A control for picking one or several options from a linear set of closely related options; useful for filtering or sorting.

Readme

ToggleButtonGroup

A control for picking one or several options from a linear set of closely related options; useful for filtering or sorting.

Installation

npm install @xsolla/xui-toggle-button-group

Imports

import { ToggleButtonGroup } from '@xsolla/xui-toggle-button-group';
import type {
  ToggleButtonGroupProps,
  ToggleButtonGroupItem,
  ToggleButtonGroupSize,
  ToggleButtonGroupAppearance,
} from '@xsolla/xui-toggle-button-group';

Quick start

onChange is typed (value: string | string[]) => void regardless of multiple, so single-select callers cast the value to string.

const [value, setValue] = useState('item1');

<ToggleButtonGroup
  items={[
    { id: 'item1', label: 'Option 1' },
    { id: 'item2', label: 'Option 2' },
    { id: 'item3', label: 'Option 3' },
  ]}
  value={value}
  onChange={(v) => setValue(v as string)}
/>;

API Reference

<ToggleButtonGroup>

| Prop | Type | Default | Description | | --- | --- | --- | --- | | items | ToggleButtonGroupItem[] | — | Items to display. | | value | string \| string[] | — | Controlled value; string for single, array for multiple. | | defaultValue | string \| string[] | — | Initial value for uncontrolled mode. | | onChange | (value: string \| string[]) => void | — | Fired when the selection changes. | | size | 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' | 'md' | Size variant. | | appearance | 'separated' \| 'united' | 'separated' | separated adds gaps; united connects items. | | view | 'horizontal' \| 'vertical' | 'horizontal' | Stack items in a row or column. | | multiple | boolean | false | Allow multiple selections. | | fullWidth | boolean | false | Stretch to fill the container. | | id | string | — | HTML id. | | testID | string | — | Test identifier. | | aria-label | string | — | Accessible label for the group. | | aria-labelledby | string | — | ID of an element that labels the group. |

Inherits ThemeOverrideProps (themeMode, themeProductContext).

ToggleButtonGroupItem

| Field | Type | Description | | --- | --- | --- | | id | string | Unique identifier. | | label | string | Display text. | | iconLeft | ReactNode | Icon shown before the label. | | iconRight | ReactNode | Icon shown after the label. | | disabled | boolean | Disable the individual item. | | aria-label | string | Accessible label for the item. |

Types

type ToggleButtonGroupSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
type ToggleButtonGroupAppearance = 'separated' | 'united';
type ToggleButtonGroupView = 'horizontal' | 'vertical';

Examples

Multiple selection

onChange is still typed (value: string | string[]) => void, so multi-select callers cast the value to string[].

const [values, setValues] = useState(['item1', 'item3']);

<ToggleButtonGroup
  multiple
  items={[
    { id: 'item1', label: 'Option 1' },
    { id: 'item2', label: 'Option 2' },
    { id: 'item3', label: 'Option 3' },
  ]}
  value={values}
  onChange={(v) => setValues(v as string[])}
/>

United appearance, full width

<ToggleButtonGroup
  appearance="united"
  fullWidth
  items={[
    { id: 'day', label: 'Day' },
    { id: 'week', label: 'Week' },
    { id: 'month', label: 'Month' },
  ]}
  defaultValue="week"
/>

Accessibility

  • role="radiogroup" for single selection, role="group" for multiple selection.
  • Arrow keys move between items; Enter/Space toggles selection.
  • aria-checked and aria-disabled reflect item state.