Skip to content
Native Animation
Base Toggle Group animation previewBase Toggle Group animation preview

This preview uses fictional demo content. See the props below for the customization options available in this component.

npx nativeanimation add base-toggle-group

Base Toggle Group

React Native Toggle Group Component

Spring-driven toggles, sliding single selection, and checkmark filter chips with configurable items, selection, sizes, variants, and theme.

Native Animation Base · Free · MIT

Add to your project

Copy the component and its assets into your app with the Native Animation CLI, or paste the agent prompt into Claude Code, Codex or Cursor once the MCP server is connected.

About this component

Spring-driven toggles, sliding single selection, and checkmark filter chips with configurable items, selection, sizes, variants, and theme.

How it works

  1. BaseToggle works on its own; BaseToggleGroup manages a single string or multiple selected values.
  2. Default single selection moves one measured indicator with the highlight spring (500/40, mass 1). Other variants fade their background and text in 200 ms.
  3. Chips reveal a checkmark with the pop spring (400/29, mass 1), remove it in 150 ms, and resize its space with the reflow spring (500/40, mass 1).
  4. Press feedback uses scale 0.97 and the press spring (550/30, mass 1). Visual heights are 32/36/40 pt; the surrounding target is at least 44 pt on iOS/web and 48 dp on Android.

For more elaborate filtering and list rearrangement, explore filter-chips-reflow.

Install

npx nativeanimation add base-toggle-group

The CLI also copies base-theme. Dependencies, if you copy by hand:

npx expo install lucide-react-native react-native-svg react-native-gesture-handler react-native-reanimated react-native-worklets

Mount a GestureHandlerRootView at the app root. Free forever. MIT.

Usage

import { BaseToggle, BaseToggleGroup } from './base-toggle-group';

<BaseToggle label="Bookmark" value={saved} onValueChange={setSaved} />
<BaseToggleGroup
  type="multiple"
  variant="chip"
  value={teams}
  onValueChange={setTeams}
  items={[
    { value: 'design', label: 'Design' },
    { value: 'engineering', label: 'Engineering' },
  ]}
  accessibilityLabel="Teams"
/>
<BaseToggleGroup
  value={view}
  onValueChange={setView}
  attached
  items={[{ value: 'list', label: 'List' }, { value: 'grid', label: 'Grid' }]}
  accessibilityLabel="View"
/>

Wrap your app in BaseThemeProvider (from base-theme) to choose light/dark and an accent; without it, pieces use the light neutral theme. The theme prop overrides the provider. Supply 16 pt icons through icon. Icon-only items use their value as their accessible name, so use readable values.

Props

PropTypeDefaultDescription
items{ value: string; label?: string; icon?: ReactNode; disabled?: boolean }[]—Group options. Values must be unique.
type'single' | 'multiple''single'Group selection mode.
valuestring | string[]empty selectionControlled group value, matching type.
onValueChange(value) => void—Receives the string or array for the selected mode. Selecting the active single item clears it.
attachedbooleanfalseJoins items with outer corner radii and shared borders.
variant'default' | 'outline' | 'chip''default'Surface and selection treatment.
size'sm' | 'default' | 'lg''default'Visual height 32, 36, or 40 pt. Chips always use 32 pt.
themeBaseThemeproviderTheme override.
styleStyleProp<ViewStyle>—Container style.
testIDstring—Root ID; group controls append -<value>.
accessibilityLabelstring—Group or standalone control name.

BaseToggle shares the appearance props above and takes the following instead of items, type, and attached:

PropTypeDefaultDescription
valueboolean—Controlled selected state.
defaultValuebooleanfalseUncontrolled initial state.
onValueChange(value: boolean) => void—Receives the selected state.
labelstring—Visible and accessible name.
iconReactNode—Optional caller-owned icon.
disabledbooleanfalsePrevents activation and dims to 0.5.

Compatibility

Expo SDK 58 · React Native 0.88 · Reanimated 4.7 · react-native-worklets 0.13. Targets iOS, Android, and web, in Expo Go and development builds. Part of Native Animation Base, a free family sharing one theme. No safe-area padding is applied. Multiple groups wrap; attached and sliding groups stay on one row, so keep their item count appropriate to the available width.

Accessibility

Single groups expose a radio group and radio items; standalone and multiple toggles expose buttons with selected and checked states. Disabled controls cannot activate. Supports screen-reader activation, Enter/Space, and a custom focus ring on web. Reduce Motion removes scaling and moving/resizing springs and applies selection immediately.

Source code

Loading public source…