Kinetik UI

Expand Toolbar

.md

Icon buttons where the picked one grows to show its name while its neighbours slide aside to make room.

v1.0.0Live on webreact-native-reanimatedreact-native-worklets
Component preview

Installation

Kinetik CLI
npx kinetik-ui add expand-toolbar

The CLI copies the source and installs native dependencies with npx expo install, so versions match your Expo SDK. With shadcn: npx shadcn@latest add https://kinetik-ui.dev/r/expand-toolbar.json

Install manually

  1. Install dependencies
    npx expo install react-native-reanimated react-native-worklets
  2. Copy the source files
    • components/kinetik/expand-toolbar.tsx
    View source files

Usage

import { ExpandToolbar } from '@/components/kinetik/expand-toolbar';

<ExpandToolbar
  accessibilityLabel="Note tools"
  items={[
    { key: 'pen', label: 'Sketch', icon: (c) => <PencilIcon color={c} /> },
    { key: 'text', label: 'Text', icon: (c) => <TextIcon color={c} /> },
    { key: 'photo', label: 'Photo', icon: (c) => <PhotoIcon color={c} /> },
  ]}
  value={tool}
  onValueChange={setTool}
/>;

Each icon is a function that receives the colour to draw in: azure for the picked tool and a muted grey for the rest.

When to use

  • Picking a mode or tool: drawing tools, editor modes, map layers, compact filters.
  • Places where icons alone are enough most of the time, but the current one should be spelled out.

When not to use

  • Navigating between screens. Use a tab bar, such as Dock Bar or Liquid Tabs.
  • More than five or six tools. The row gets too wide on a phone once one is expanded.

Notes

  • Labels are measured once, out of sight, so each button grows by exactly its label's width.
  • The toolbar sizes to its content. Centre it with alignSelf: 'center' or put it in a row.
  • With reduced motion the picked button shows its label without growing.

Props

ExpandToolbarProps

PropTypeDefaultDescription
itemsrequiredreadonly ExpandToolbarItem[]—
valuerequiredstring—
onValueChangerequired(key: string) => void—
accessibilityLabelrequiredstring—Names the toolbar, e.g. "Drawing tools".
hapticsbooleantrueA tick on change. Defaults to true.
testIDstring—
styleStyleProp<ViewStyle>—

Performance and accessibility

Performance

Budget
One shared value per button; two widths animate on a change, so the row lays out for the length of the spring. Nothing runs at rest.
Measured

Pixel 9 emulator, API 35, release build · interaction median 1.10× the system Settings app on the same emulator (indicative only) · no frames drawn at rest · 151 MB app memory. Measured with its own script that taps each tool in turn, since the default gestures miss the toolbar.

Real-device measurement pending.

Accessibility

Reduced motion
The picked button shows its label at once, without growing.
Screen readers
A toolbar of buttons named by their labels, the picked one marked as selected.
Touch target
Every button is at least 44 pt square.

Source files

components/kinetik/expand-toolbar.tsx is in the Code tab of the preview above.