Flip Button
animate-ui/components-buttons-flipFreeComponent
A button that flips between two states on hover.
Install it
npx shadcn@latest add https://animate-ui.com/r/components-buttons-flip.jsonSource
1import * as React from 'react';2import { type VariantProps } from 'class-variance-authority';34import {5 FlipButton as FlipButtonPrimitive,6 FlipButtonFront as FlipButtonFrontPrimitive,7 FlipButtonBack as FlipButtonBackPrimitive,8 type FlipButtonProps as FlipButtonPrimitiveProps,9 type FlipButtonFrontProps as FlipButtonFrontPrimitiveProps,10 type FlipButtonBackProps as FlipButtonBackPrimitiveProps,11} from '@/components/animate-ui/primitives/buttons/flip';12import { getStrictContext } from '@/lib/get-strict-context';13import { buttonVariants } from '@/components/animate-ui/components/buttons/button';14import { cn } from '@/lib/utils';1516type FlipButtonContextType = VariantProps<typeof buttonVariants>;1718const [FlipButtonProvider, useFlipButton] =19 getStrictContext<FlipButtonContextType>('FlipButtonContext');2021type FlipButtonProps = FlipButtonPrimitiveProps &22 VariantProps<typeof buttonVariants>;2324function FlipButton({ variant, size, ...props }: FlipButtonProps) {25 return (26 <FlipButtonProvider value={{ variant, size }}>27 <FlipButtonPrimitive {...props} />28 </FlipButtonProvider>29 );30}3132type FlipButtonFrontProps = FlipButtonFrontPrimitiveProps &33 VariantProps<typeof buttonVariants>;3435function FlipButtonFront({36 variant,37 size,38 className,39 ...props40}: FlipButtonFrontProps) {41 const { variant: buttonVariant, size: buttonSize } = useFlipButton();42 return (43 <FlipButtonFrontPrimitive44 className={cn(45 buttonVariants({46 variant: variant ?? buttonVariant,47 size: size ?? buttonSize,48 className,49 }),50 )}51 {...props}52 />53 );54}5556type FlipButtonBackProps = FlipButtonBackPrimitiveProps &57 VariantProps<typeof buttonVariants>;5859function FlipButtonBack({60 variant,61 size,62 className,63 ...props64}: FlipButtonBackProps) {65 const { variant: buttonVariant, size: buttonSize } = useFlipButton();66 return (67 <FlipButtonBackPrimitive68 className={cn(69 buttonVariants({70 variant: variant ?? buttonVariant,71 size: size ?? buttonSize,72 className,73 }),74 )}75 {...props}76 />77 );78}7980export {81 FlipButton,82 FlipButtonFront,83 FlipButtonBack,84 type FlipButtonProps,85 type FlipButtonFrontProps,86 type FlipButtonBackProps,87};
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 |
