Rendyn

Component library

189 components

Interaction

Action Swap

Action Swap coordinates named items with text and icon transitions.

React Tailwind CSS

Practical React example

Switch between related button actions while keeping the current action’s label clear.

Before you copy and paste

Keep the example in the React rendering environment required by the imported component. Copy components/motion/action-swap.tsx and its returned support files from the Code tab; preserve the project-relative paths.

Listed package dependencies: clsx, lucide-react, motion, react, tailwind-merge.

Use the Code tab for the component files and installation instructions, then adapt the imports in this example to your project.

Switch between related button actions while keeping the current action’s label clear

// Usage adapted from beUI's pinned MIT source.
// Copyright (c) 2026 Saurabh Chauhan. See ./LICENSES.md.
'use client';

import { useState } from 'react';
import { ActionSwapButton } from '@/components/motion/action-swap';

const views = [{ id: 'preview', label: 'Preview' }, { id: 'details', label: 'Details' }];

export function ViewAction() {
  const [view, setView] = useState('preview');
  return (
    <section aria-label="Choose a view">
      <ActionSwapButton items={views} value={view} onValueChange={setView} />
      <p>Selected view: {view}</p>
    </section>
  );
}

Usage example adapted from beUI's pinned MIT source. Retain the source licence notices when copying.

Use stable item IDs and keep the selected value in parent state when another part of the UI depends on it. Treat the callback as an action choice, not as persistence.

Customization

ActionSwapButtonProps.items
Required; ActionSwapItem[].
ActionSwapButtonProps.value
Optional; string.
ActionSwapButtonProps.defaultValue
Optional; string.
ActionSwapButtonProps.onValueChange
Optional; (value: string, item: ActionSwapItem) => void.
ActionSwapButtonProps.variant
Optional; ActionSwapButtonVariant.
ActionSwapButtonProps.size
Optional; ActionSwapButtonSize.
ActionSwapButtonProps.animation
Optional; ActionSwapAnimation.
ActionSwapButtonProps.iconOnly
Optional; boolean.
ActionSwapButtonProps.cycle
Optional; boolean.
ActionSwapTextProps.value
Required; string.
ActionSwapTextProps.children
Required; ReactNode.
ActionSwapTextProps.animation
Optional; ActionSwapAnimation.
ActionSwapTextProps.className
Optional; string.
ActionSwapIconProps.value
Required; string.

Integration notes

  • Cycling actions must remain understandable without watching the transition.
  • Give icon-only variants a useful accessible name and verify that keyboard activation invokes the intended item.

Component source: beUI documentation . These examples describe the version imported into Rendyn. Upstream APIs may have changed; retain the source licence notices when adapting the code.

Better with your agent

Give your agent taste.

The best way to use Rendyn is through MCP. Let your agent find the right component, compare previews and bring the source into your project.

All components are free. Sign up only to connect MCP.

Connect to MCP