Skip to content
Back to skills

Toggle

ASecurity

On/off switch component with animated handle using Framer Motion spring animation. Supports sizes and custom animation configuration.

  • 4 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 27, 2026
developmenttypescriptnodespring

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add reaviz/skills --skill toggle --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Toggle?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Toggle
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/reaviz-toggle/badge)](https://www.skillsdirectory.com/skills/reaviz-toggle)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Toggle

On/off switch component with animated handle using Framer Motion spring animation. Supports sizes and custom animation configuration.

## Import

```tsx
import { Toggle } from 'reablocks';
```

## Toggle Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `checked` | `boolean` | — | Whether the toggle is on (required) |
| `disabled` | `boolean` | — | Disable the toggle |
| `animated` | `boolean` | `true` | Enable spring animation |
| `animation` | `MotionNodeAnimationOptions` | — | Custom Framer Motion animation config |
| `size` | `'small' \| 'medium' \| 'large'` | `'medium'` | Toggle size |
| `onChange` | `(value: boolean) => void` | — | Change handler (receives new state) |
| `onBlur` | `(event: FocusEvent) => void` | — | Blur handler |
| `className` | `string` | — | Additional CSS classes |
| `theme` | `ToggleTheme` | — | Per-instance theme override |

Renders with `role="switch"`, `aria-checked`, keyboard support (Space).

## Basic Usage

```tsx
const [checked, setChecked] = useState(false);
<Toggle checked={checked} onChange={setChecked} />
```

## Sizes

```tsx
<Toggle checked={checked} onChange={setChecked} size="small" />
<Toggle checked={checked} onChange={setChecked} size="medium" />
<Toggle checked={checked} onChange={setChecked} size="large" />
```

## Disabled

```tsx
<Toggle disabled checked />
<Toggle disabled checked={false} />
```

## Custom Animation

```tsx
<Toggle
  checked={checked}
  onChange={setChecked}
  animation={{
    initial: { scale: 0.7, opacity: 0.5 },
    animate: { scale: 1, opacity: 1, transition: { type: 'spring', stiffness: 300, damping: 20 } },
    whileHover: { scale: 1.1 },
    whileTap: { scale: 0.9 }
  }}
/>
```

## No Animation

```tsx
<Toggle checked={checked} onChange={setChecked} animation={{ transition: { duration: 0 } }} />
```

## ToggleTheme Interface

```typescript
interface ToggleTheme {
  base: string;                // Track styles (flex, rounded-full, bg, border)
  disabled: string;            // Disabled track
  checked: string;             // Checked track (justify-end, bg change)
  disabledAndChecked: string;  // Disabled + checked track
  handle: {
    base: string;              // Handle styles (rounded-full, bg)
    sizes: { small, medium, large };
    disabled: string;
    disabledAndChecked: string;
  };
  sizes: { small, medium, large };  // Track dimensions per size
}
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.