UI Button
remocn/buttonFreeComponent
A button whose idle/hover/press/loading/success state is a pure function of the timeline; the loading state composes the Spinner motion atom.
Install it
npx shadcn@latest add https://www.remocn.dev/r/button.jsonSource
1"use client";23import { Spinner } from "@/components/remocn/spinner";4import { mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";56export type ButtonState = "idle" | "hover" | "press" | "loading" | "success";78type ButtonVariant =9 | "default"10 | "secondary"11 | "destructive"12 | "outline"13 | "ghost";1415type ButtonSize = "sm" | "default" | "lg";1617export interface ButtonProps {18 state?: ButtonState;19 style?: ButtonStyle;20 label?: string;21 variant?: ButtonVariant;22 size?: ButtonSize;23 theme?: Partial<RemocnTheme>;24 primary?: string;25 speed?: number;26 align?: "start" | "center" | "end";27 className?: string;28}2930function justify(align: "start" | "center" | "end"): string {31 return align === "start"32 ? "flex-start"33 : align === "end"34 ? "flex-end"35 : "center";36}3738const CHECK_PATH_LENGTH = 14;3940const SIZE_STYLES: Record<41 ButtonSize,42 { height: number; padding: string; fontSize: number; gap: number }43> = {44 sm: { height: 32, padding: "0 12px", fontSize: 13, gap: 6 },45 default: { height: 40, padding: "0 20px", fontSize: 15, gap: 8 },46 lg: { height: 48, padding: "0 28px", fontSize: 17, gap: 10 },47};4849interface VariantTokens {50 bg: string;51 fg: string;52 hoverBg: string;53 border: string;54}5556function variantTokens(57 variant: ButtonVariant,58 theme: RemocnTheme,59): VariantTokens {60 const variants = {61 secondary: {62 bg: theme.secondary,63 fg: theme.secondaryForeground,64 hoverBg: mixOklch(theme.secondary, theme.muted, 1),65 border: "transparent",66 },67 destructive: {68 bg: theme.destructive,69 fg: theme.destructiveForeground,70 hoverBg: mixOklch(theme.destructive, theme.foreground, 0.12),71 border: "transparent",72 },73 outline: {74 bg: "transparent",75 fg: theme.foreground,76 hoverBg: theme.accent,77 border: theme.border,78 },79 ghost: {80 bg: "transparent",81 fg: theme.foreground,82 hoverBg: theme.accent,83 border: "transparent",84 },85 default: {86 bg: theme.primary,87 fg: theme.primaryForeground,88 hoverBg: mixOklch(theme.primary, theme.foreground, 0.1),89 border: "transparent",90 },91 };9293 return variants[variant] ?? variants.default;94}9596export interface ButtonStyle {97 translateY: number;98 scale: number;99 background: string;100 labelOpacity: number;101 spinnerOpacity: number;102 checkOpacity: number;103}104105export interface ButtonStyleContext {106 restBg: string;107 hoverBg: string;108 pressBg: string;109// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from remocn
All 277 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| UI Accordionaccordion | remocn | Components | Free | 1 dep · 2 files | |
| UI AI Prompt Flowai-prompt-flow | remocn | Components | Free | 1 dep | |
| UI Alert Dialogalert-dialog | remocn | Components | Free | 1 dep · 2 files | |
| Animated Bar Chartanimated-bar-chart | remocn | Components | Free | 1 dep | |
| Animated Line Chartanimated-line-chart | remocn | Components | Free | 1 dep | |
| ASCII Dissolveascii-dissolve | remocn | Components | Free | 2 deps | |
| ASCII Renderascii-render | remocn | Components | Free | 1 dep | |
| Backdropbackdrop | remocn | Components | Free | 1 dep |
