Skip to content

secondsky/claude-skills / plugins/base-ui-react/skills/base-ui-react

base-ui-react

Verified

MUI Base UI unstyled React components with Floating UI. Use for accessible components, Radix UI migration, render props API, or encountering positioning, popup, v1.0 rc / pre-GA issues.

scripts/migrate-radix-component.sh

View on GitHub
#!/bin/bash
# Automated Radix UI → Base UI migration helper
# WARNING: This script modifies files. Commit your changes first!

set -e

if [ $# -eq 0 ]; then
  echo "Usage: $0 <file.tsx>"
  echo ""
  echo "Example:"
  echo "  $0 src/components/Dialog.tsx"
  echo ""
  echo "⚠️  WARNING: This script modifies files. Commit your changes first!"
  exit 1
fi

FILE="$1"

if [ ! -f "$FILE" ]; then
  echo "❌ Error: File not found: $FILE"
  exit 1
fi

echo "🔄 Migrating $FILE from Radix UI to Base UI..."
echo ""

# Create backup. If a previous .radix-backup exists (script was run before),
# preserve it as .radix-backup.<timestamp> BEFORE taking the new backup so
# the truly-original pre-migration state survives multiple runs. This makes
# the script idempotent: re-runs no longer overwrite the original snapshot.
BACKUP="${FILE}.radix-backup"
if [ -f "$BACKUP" ]; then
    TS="$(date +%Y%m%d%H%M%S)"
    PREV_BACKUP="${BACKUP}.${TS}"
    mv "$BACKUP" "$PREV_BACKUP"
    echo "ℹ️  Existing backup moved aside: $PREV_BACKUP"
fi
cp "$FILE" "$BACKUP"
echo "✅ Created backup: $BACKUP"

# Perform migrations
echo "🔧 Applying transformations..."

# 1. Update imports
sed -i 's/import \* as Dialog from "@radix-ui\/react-dialog"/import { Dialog } from "@base-ui-components\/react\/dialog"/' "$FILE"
sed -i 's/import \* as Popover from "@radix-ui\/react-popover"/import { Popover } from "@base-ui-components\/react\/popover"/' "$FILE"
sed -i 's/import \* as Select from "@radix-ui\/react-select"/import { Select } from "@base-ui-components\/react\/select"/' "$FILE"
sed -i 's/import \* as Tooltip from "@radix-ui\/react-tooltip"/import { Tooltip } from "@base-ui-components\/react\/tooltip"/' "$FILE"
sed -i 's/import \* as Accordion from "@radix-ui\/react-accordion"/import { Accordion } from "@base-ui-components\/react\/accordion"/' "$FILE"

# 2. Replace component names
sed -i 's/\.Content\b/.Popup/g' "$FILE"
sed -i 's/\.Overlay\b/.Backdrop/g' "$FILE"

# 3. Replace props
sed -i 's/\balign="/alignment="/g' "$FILE"

# 4. Add TODO markers for manual fixes
echo ""
echo "⚠️  Manual fixes required:"
echo ""
echo "1. Replace asChild with render props:"
echo "   <Trigger asChild><button /></Trigger>"
echo "   → <Trigger render={(props) => <button {...props} />} />"
echo ""
echo "2. Add Positioner wrapper for Select, Popover, Tooltip:"
echo "   <Portal><Popup /></Portal>"
echo "   → <Positioner side=\"top\"><Portal><Popup /></Portal></Positioner>"
echo ""
echo "3. Make Portal explicit if not already"
echo ""
echo "4. Ensure all render props spread {...props}"
echo ""

# Add TODO comment at top of file (only if not already present, so the script
# is idempotent across re-runs and doesn't stack duplicate markers).
if ! grep -q '^// TODO: Complete Base UI migration' "$FILE" 2>/dev/null; then
    sed -i '1i // TODO: Complete Base UI migration - check render props, Positioner wrappers, and Portal usage' "$FILE"
fi

echo "✅ Automatic transformations complete!"
echo ""
echo "📝 Next steps:"
echo "  1. Review changes: git diff $FILE"
echo "  2. Manually fix asChild → render props"
echo "  3. Add Positioner wrappers where needed"
echo "  4. Test thoroughly"
echo "  5. Remove TODO comment when done"
echo ""
echo "📚 See references/migration-from-radix.md for complete guide"
echo ""
echo "To restore backup:"
echo "  mv $BACKUP $FILE"
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 321kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 197kUpdated Claude CodeCodexVerifiedInstall