Icon Button
animate-ui/components-buttons-iconFreeComponent
An icon button component with a variety of styles and animations.
Install it
npx shadcn@latest add https://animate-ui.com/r/components-buttons-icon.jsonSource
1'use client';23import * as React from 'react';4import { cva, type VariantProps } from 'class-variance-authority';56import {7 Button as ButtonPrimitive,8 type ButtonProps as ButtonPrimitiveProps,9} from '@/components/animate-ui/primitives/buttons/button';10import { cn } from '@/lib/utils';11import {12 Particles,13 ParticlesEffect,14} from '@/components/animate-ui/primitives/effects/particles';1516const buttonVariants = cva(17 "flex items-center justify-center rounded-md transition-[box-shadow,_color,_background-color,_border-color,_outline-color,_text-decoration-color,_fill,_stroke] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",18 {19 variants: {20 variant: {21 default:22 'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',23 accent: 'bg-accent text-accent-foreground shadow-xs hover:bg-accent/90',24 destructive:25 'bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',26 outline:27 'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',28 secondary:29 'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80',30 ghost:31 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',32 link: 'text-primary underline-offset-4 hover:underline',33 },34 size: {35 default: 'size-9',36 xs: "size-7 [&_svg:not([class*='size-'])]:size-3.5 rounded-md",37 sm: 'size-8 rounded-md',38 lg: 'size-10 rounded-md',39 },40 },41 defaultVariants: {42 variant: 'default',43 size: 'default',44 },45 },46);4748type IconButtonProps = Omit<ButtonPrimitiveProps, 'asChild'> &49 VariantProps<typeof buttonVariants> & {50 children?: React.ReactNode;51 };5253function IconButton({54 className,55 onClick,56 variant,57 size,58 children,59 ...props60}: IconButtonProps) {61 const [isActive, setIsActive] = React.useState(false);62 const [key, setKey] = React.useState(0);6364 return (65 <Particles asChild animate={isActive} key={key}>66 <ButtonPrimitive67// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from Animate UI
All 580 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Avatar Groupcomponents-animate-avatar-group | Animate UI | Components | Free | 1 dep | |
| Codecomponents-animate-code | Animate UI | Components | Free | 1 dep | |
| Code Tabscomponents-animate-code-tabs | Animate UI | Components | Free | 1 dep | |
| Cursorcomponents-animate-cursor | Animate UI | Components | Free | no deps | |
| GitHub Stars Wheelcomponents-animate-github-stars-wheel | Animate UI | Components | Free | 1 dep | |
| Tabscomponents-animate-tabs | Animate UI | Components | Free | no deps | |
| Tooltipcomponents-animate-tooltip | Animate UI | Components | Free | 1 dep | |
| Bubble Backgroundcomponents-backgrounds-bubble | Animate UI | Components | Free | 1 dep |
