Performance
Not testedNot tested
Multi ButtonMITButtonGodUI
A button React component by Lucas Bassetti. Collected unchanged from GodUI under the MIT licence and shown here live.
Quality report
The grade and score come from automated checks run at build or test time. If a check did not run, it is marked Not tested — numbers are never invented.
Not tested
Not tested
Not tested
Not tested
Figures come from an automated script, not from hand-written samples.
Shown at real size.
The copy starts with the licence notice. Keep it when you use the code.
<div id="root"></div>:root{--bg:#f6f4f0;--ink:#17181a;--background:40 20% 96%;--foreground:24 10% 8%;--card:0 0% 100%}html,body{min-height:100%;margin:0;background:var(--bg);color:var(--ink)}html,body{height:100%;overflow:hidden}body{display:grid;place-items:center}#root{display:grid;place-items:center;max-width:100%;max-height:100%;box-sizing:border-box;padding:16px;color:hsl(var(--foreground))}#root.full{width:100%;height:100%;padding:0}@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-play-state:paused!important;transition-duration:0s!important}}
/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial}}}@layer theme{:root,:host{--font-sans:var(--font-sans);--font-serif:var(--font-serif);--font-mono:var(--font-mono);--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--font-weight-medium:500;--radius-md:calc(var(--radius) - 2px);--radius-lg:var(--radius);--radius-xl:calc(var(--radius) + 4px);--radius-2xl:1rem;--shadow-2xs:var(--shadow-2xs);--shadow-xs:var(--shadow-xs);--shadow-sm:var(--shadow-sm);--shadow-md:var(--shadow-md);--shadow-lg:var(--shadow-lg);--shadow-xl:var(--shadow-xl);--shadow-2xl:var(--shadow-2xl);--drop-shadow-sm:0 1px 2px #00000026;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--shadow:var(--shadow)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.invisible{visibility:hidden}.visible{visibility:visible}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.top-0{top:0}.left-0{left:0}.isolate{isolation:isolate}.z-base{z-index:var(--z-base)}.z-raised{z-index:var(--z-raised)}.my-2{margin-block:calc(var(--spacing) * 2)}.-ml-1{margin-left:calc(var(--spacing) * -1)}.contents{display:contents}.flex{display:flex}.inline-flex{display:inline-flex}.size-3\.5{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.size-\[18px\]{width:18px;height:18px}.h-0{height:0}.h-10{height:calc(var(--spacing) * 10)}.h-full{height:100%}.min-h-4{min-height:calc(var(--spacing) * 4)}.w-0{width:0}.w-28{width:calc(var(--spacing) * 28)}.w-full{width:100%}.w-px{width:1px}.max-w-\[34rem\]{max-width:34rem}.max-w-full{max-width:100%}.min-w-4{min-width:calc(var(--spacing) * 4)}.shrink-0{flex-shrink:0}.transform{transform:var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, )}.cursor-pointer{cursor:pointer}.resize{resize:both}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-stretch{align-items:stretch}.justify-center{justify-content:center}.justify-start{justify-content:flex-start}.gap-1{gap:var(--spacing)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-8{gap:calc(var(--spacing) * 8)}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:2147483647px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-border,.border-border\/70{border-color:var(--border)}@supports (color:color-mix(in lab, red, red)){.border-border\/70{border-color:color-mix(in oklab, var(--border) 70%, transparent)}}.bg-\[var\(--multi-button-highlight\)\]{background-color:var(--multi-button-highlight)}.bg-background{background-color:var(--background)}.bg-border\/70{background-color:var(--border)}@supports (color:color-mix(in lab, red, red)){.bg-border\/70{background-color:color-mix(in oklab, var(--border) 70%, transparent)}}.bg-card\/60{background-color:var(--card)}@supports (color:color-mix(in lab, red, red)){.bg-card\/60{background-color:color-mix(in oklab, var(--card) 60%, transparent)}}.bg-card\/70{background-color:var(--card)}@supports (color:color-mix(in lab, red, red)){.bg-card\/70{background-color:color-mix(in oklab, var(--card) 70%, transparent)}}.bg-muted\/50{background-color:var(--muted)}@supports (color:color-mix(in lab, red, red)){.bg-muted\/50{background-color:color-mix(in oklab, var(--muted) 50%, transparent)}}.bg-primary{background-color:var(--primary)}.bg-primary-foreground\/20{background-color:var(--primary-foreground)}@supports (color:color-mix(in lab, red, red)){.bg-primary-foreground\/20{background-color:color-mix(in oklab, var(--primary-foreground) 20%, transparent)}}.bg-secondary{background-color:var(--secondary)}.bg-secondary-foreground\/15{background-color:var(--secondary-foreground)}@supports (color:color-mix(in lab, red, red)){.bg-secondary-foreground\/15{background-color:color-mix(in oklab, var(--secondary-foreground) 15%, transparent)}}.p-1{padding:var(--spacing)}.p-6{padding:calc(var(--spacing) * 6)}.px-3{padding-inline:calc(var(--spacing) * 3)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.pr-2{padding-right:calc(var(--spacing) * 2)}.text-center{text-align:center}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.leading-none{--tw-leading:1;line-height:1}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.whitespace-nowrap{white-space:nowrap}.text-foreground{color:var(--foreground)}.text-muted-foreground{color:var(--muted-foreground)}.text-primary-foreground{color:var(--primary-foreground)}.text-secondary-foreground{color:var(--secondary-foreground)}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal, ) var(--tw-slashed-zero, ) var(--tw-numeric-figure, ) var(--tw-numeric-spacing, ) var(--tw-numeric-fraction, )}.accent-primary{accent-color:var(--primary)}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-\[0\.14\]{opacity:.14}.shadow-sm{--tw-shadow:var(--shadow-sm);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-xs{--tw-shadow:var(--shadow-xs);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-border\/60{--tw-ring-color:var(--border)}@supports (color:color-mix(in lab, red, red)){.ring-border\/60{--tw-ring-color:color-mix(in oklab, var(--border) 60%, transparent)}}.ring-border\/80{--tw-ring-color:var(--border)}@supports (color:color-mix(in lab, red, red)){.ring-border\/80{--tw-ring-color:color-mix(in oklab, var(--border) 80%, transparent)}}.ring-primary\/20{--tw-ring-color:var(--primary)}@supports (color:color-mix(in lab, red, red)){.ring-primary\/20{--tw-ring-color:color-mix(in oklab, var(--primary) 20%, transparent)}}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.drop-shadow-sm{--tw-drop-shadow-size:drop-shadow(0 1px 2px var(--tw-drop-shadow-color,#00000026));--tw-drop-shadow:drop-shadow(var(--drop-shadow-sm));filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.filter{filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.\[transition\:opacity_150ms_ease\]{transition:opacity .15s}.\[transition\:transform_200ms_cubic-bezier\(0\.3\,0\.7\,0\.4\,1\)\]{transition:transform .2s cubic-bezier(.3,.7,.4,1)}.\[transition\:transform_200ms_ease-out\]{transition:transform .2s ease-out}.\[transition\:transform_300ms_cubic-bezier\(0\.3\,0\.7\,0\.4\,1\.5\)\]{transition:transform .3s cubic-bezier(.3,.7,.4,1.5)}.\[transition\:width_200ms_cubic-bezier\(0\.3\,0\.7\,0\.4\,1\)\,background-color_150ms_ease\,color_150ms_ease\,scale_120ms_ease\]{transition:width .2s cubic-bezier(.3,.7,.4,1),background-color .15s,color .15s,scale .12s}.\[transition\:width_200ms_cubic-bezier\(0\.3\,0\.7\,0\.4\,1\)\,opacity_150ms_ease\]{transition:width .2s cubic-bezier(.3,.7,.4,1),opacity .15s}.\[transition\:width_200ms_cubic-bezier\(0\.3\,0\.7\,0\.4\,1\)\]{transition:width .2s cubic-bezier(.3,.7,.4,1)}.\[transition\:width_200ms_ease-out\,background-color_150ms_ease\,color_150ms_ease\,scale_120ms_ease\]{transition:width .2s ease-out,background-color .15s,color .15s,scale .12s}.\[transition\:width_200ms_ease-out\,opacity_200ms_ease-out\]{transition:width .2s ease-out,opacity .2s ease-out}.\[transition\:width_200ms_ease-out\]{transition:width .2s ease-out}.\[transition\:width_300ms_cubic-bezier\(0\.3\,0\.7\,0\.4\,1\.5\)\,background-color_150ms_ease\,color_150ms_ease\,scale_120ms_ease\]{transition:width .3s cubic-bezier(.3,.7,.4,1.5),background-color .15s,color .15s,scale .12s}.\[transition\:width_300ms_cubic-bezier\(0\.3\,0\.7\,0\.4\,1\.5\)\,opacity_150ms_ease\]{transition:width .3s cubic-bezier(.3,.7,.4,1.5),opacity .15s}.\[transition\:width_300ms_cubic-bezier\(0\.3\,0\.7\,0\.4\,1\.5\)\]{transition:width .3s cubic-bezier(.3,.7,.4,1.5)}.ring-inset{--tw-ring-inset:inset}@media (hover:hover){.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-primary-foreground\/10:hover{background-color:var(--primary-foreground)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-primary-foreground\/10:hover{background-color:color-mix(in oklab, var(--primary-foreground) 10%, transparent)}}.hover\:bg-secondary-foreground\/10:hover{background-color:var(--secondary-foreground)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-secondary-foreground\/10:hover{background-color:color-mix(in oklab, var(--secondary-foreground) 10%, transparent)}}.hover\:text-accent-foreground:hover{color:var(--accent-foreground)}}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:z-raised:focus-visible{z-index:var(--z-raised)}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus-visible\:ring-ring:focus-visible{--tw-ring-color:var(--ring)}.focus-visible\:ring-inset:focus-visible{--tw-ring-inset:inset}.active\:scale-\[0\.96\]:active{scale:.96}.active\:bg-accent\/80:active{background-color:var(--accent)}@supports (color:color-mix(in lab, red, red)){.active\:bg-accent\/80:active{background-color:color-mix(in oklab, var(--accent) 80%, transparent)}}.active\:bg-primary-foreground\/20:active{background-color:var(--primary-foreground)}@supports (color:color-mix(in lab, red, red)){.active\:bg-primary-foreground\/20:active{background-color:color-mix(in oklab, var(--primary-foreground) 20%, transparent)}}.active\:bg-secondary-foreground\/20:active{background-color:var(--secondary-foreground)}@supports (color:color-mix(in lab, red, red)){.active\:bg-secondary-foreground\/20:active{background-color:color-mix(in oklab, var(--secondary-foreground) 20%, transparent)}}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}@media (prefers-reduced-motion:reduce){.motion-reduce\:\[transition\:none\]{transition:none}}@media not all and (min-width:40rem){.max-sm\:gap-6{gap:calc(var(--spacing) * 6)}.max-sm\:p-4{padding:calc(var(--spacing) * 4)}}}:root,.light,:root[data-theme=light]{--background:oklch(100% 0 0);--foreground:oklch(14.5% 0 0);--card:oklch(100% 0 0);--card-foreground:oklch(14.5% 0 0);--popover:oklch(100% 0 0);--popover-foreground:oklch(14.5% 0 0);--primary:oklch(20.5% 0 0);--primary-foreground:oklch(98.5% 0 0);--secondary:oklch(97% 0 0);--secondary-foreground:oklch(20.5% 0 0);--accent:oklch(97% 0 0);--accent-foreground:oklch(20.5% 0 0);--muted:oklch(97% 0 0);--muted-foreground:oklch(55.6% 0 0);--destructive:oklch(57.7% .245 27.325);--border:oklch(92.2% 0 0);--input:oklch(92.2% 0 0);--ring:oklch(70.8% 0 0);--chart-1:oklch(64.6% .222 41.116);--chart-2:oklch(60% .118 184.704);--chart-3:oklch(39.8% .07 227.392);--chart-4:oklch(82.8% .189 84.429);--chart-5:oklch(76.9% .188 70.08);--sidebar:oklch(98.5% 0 0);--sidebar-foreground:oklch(14.5% 0 0);--sidebar-primary:oklch(20.5% 0 0);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(97% 0 0);--sidebar-accent-foreground:oklch(20.5% 0 0);--sidebar-border:oklch(92.2% 0 0);--sidebar-ring:oklch(70.8% 0 0);--font-sans:var(--font-geist-sans,"Geist", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif);--font-serif:var(--font-geist-sans,"Geist", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif);--font-mono:var(--font-geist-mono,"Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);--radius:.625rem;--shadow-2xs:0 1px 2px #00000005;--shadow-xs:0 1px 3px #0000000a;--shadow-sm:0 2px 6px #0000000d;--shadow:0 4px 12px #0000000f;--shadow-md:0 8px 20px #00000014;--shadow-lg:0 16px 32px #0000001a;--shadow-xl:0 24px 48px #0000001f;--shadow-2xl:0 40px 80px #00000029;--syntax-plain:oklch(20% .036 266);--syntax-punctuation:oklch(54% .022 266);--syntax-keyword:oklch(52% .19 302);--syntax-property:oklch(56% .11 90);--syntax-string:oklch(52% .106 168);--syntax-comment:oklch(63% .016 266);--syntax-number:oklch(54% .115 235);--inline-code-bg:var(--muted);--inline-code-fg:var(--foreground);--inline-code-border:var(--border);--code-block:oklch(97.8% 0 0);--code-block-foreground:oklch(20.5% 0 0);--code-block-border:oklch(92.2% 0 0);--search-bg:var(--card);--search-fg:var(--muted-foreground);--search-border:var(--border);--search-kbd-bg:var(--muted);--search-kbd-fg:var(--muted-foreground);--search-placeholder:var(--muted-foreground);--search-highlight-bg:var(--primary);--search-highlight-fg:var(--primary-foreground);--theme-panel-bg:var(--card);--theme-panel-border:var(--border);--theme-panel-fg:var(--muted-foreground);--theme-panel-active-bg:var(--muted);--theme-panel-active-fg:var(--foreground);--z-base:0;--z-raised:10;--z-overlay:20;--z-sticky:30;--z-popover:40;--z-modal:50;--z-toast:60;--color-bg:var(--background);--color-fg:var(--foreground);--color-border:var(--border);--color-primary:var(--primary);--color-primary-fg:var(--primary-foreground);--color-secondary-bg:var(--secondary);--color-secondary-fg:var(--secondary-foreground);--color-destructive:var(--destructive);--color-destructive-fg:oklch(100% 0 0);--glow-highlight:61, 102, 223;--color-primary-rgb:61, 102, 223;--radius-md:calc(var(--radius) - 2px);--radius-lg:var(--radius);--god-gradient:linear-gradient(135deg, oklch(55% .19 266) 0%, oklch(100% 0 0) 50%, oklch(85% .12 90) 100%);--god-glow:0 0 24px oklch(55% .19 266/.14), 0 0 80px oklch(85% .12 90/.06);--rainbow-1:oklch(55% .19 266);--rainbow-2:oklch(68% .16 305);--rainbow-3:oklch(82% .1 185);--rainbow-4:oklch(78% .12 14);--rainbow-5:oklch(80% .13 90);--rainbow-speed:2s}@media (color-gamut:p3){:root,.light{--syntax-string:oklch(52% .13 168);--syntax-number:oklch(54% .13 235)}}@media (prefers-color-scheme:dark){:root:not(.light){--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20.5% 0 0);--card-foreground:oklch(98.5% 0 0);--popover:oklch(20.5% 0 0);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(92.2% 0 0);--primary-foreground:oklch(20.5% 0 0);--secondary:oklch(26.9% 0 0);--secondary-foreground:oklch(98.5% 0 0);--accent:oklch(26.9% 0 0);--accent-foreground:oklch(98.5% 0 0);--muted:oklch(26.9% 0 0);--muted-foreground:oklch(70.8% 0 0);--destructive:oklch(70.4% .191 22.216);--border:oklch(100% 0 0/.1);--input:oklch(100% 0 0/.15);--ring:oklch(55.6% 0 0);--chart-1:oklch(48.8% .243 264.376);--chart-2:oklch(69.6% .17 162.48);--chart-3:oklch(76.9% .188 70.08);--chart-4:oklch(62.7% .265 303.9);--chart-5:oklch(64.5% .246 16.439);--sidebar:oklch(20.5% 0 0);--sidebar-foreground:oklch(98.5% 0 0);--sidebar-primary:oklch(48.8% .243 264.376);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(26.9% 0 0);--sidebar-accent-foreground:oklch(98.5% 0 0);--sidebar-border:oklch(100% 0 0/.1);--sidebar-ring:oklch(55.6% 0 0);--syntax-plain:oklch(93.5% .01 266);--syntax-punctuation:oklch(65% .02 266);--syntax-keyword:oklch(78% .135 302);--syntax-property:oklch(83% .12 90);--syntax-string:oklch(80% .13 168);--syntax-comment:oklch(58% .02 266);--syntax-number:oklch(80% .12 224);--code-block:oklch(18.5% 0 0);--code-block-foreground:oklch(98.5% 0 0);--code-block-border:oklch(27% 0 0);--inline-code-bg:var(--muted);--inline-code-fg:var(--foreground);--inline-code-border:var(--border);--search-bg:var(--card);--search-fg:var(--muted-foreground);--search-border:var(--border);--search-kbd-bg:var(--muted);--search-kbd-fg:var(--muted-foreground);--search-placeholder:var(--muted-foreground);--search-highlight-bg:var(--primary);--search-highlight-fg:var(--primary-foreground);--theme-panel-bg:var(--card);--theme-panel-border:var(--border);--theme-panel-fg:var(--muted-foreground);--theme-panel-active-bg:var(--muted);--theme-panel-active-fg:var(--foreground);--shadow-2xs:0 1px 2px #0000001f;--shadow-xs:0 1px 3px #00000026;--shadow-sm:0 2px 6px #0003;--shadow:0 4px 12px #00000040;--shadow-md:0 8px 20px #0000004d;--shadow-lg:0 16px 32px #00000059;--shadow-xl:0 24px 48px #0006;--shadow-2xl:0 40px 80px #00000080;--color-bg:var(--background);--color-fg:var(--foreground);--color-border:var(--border);--color-primary:var(--primary);--color-primary-fg:var(--primary-foreground);--color-secondary-bg:var(--secondary);--color-secondary-fg:var(--secondary-foreground);--color-destructive:var(--destructive);--color-destructive-fg:oklch(100% 0 0);--glow-highlight:66, 108, 229;--color-primary-rgb:66, 108, 229;--radius-md:calc(var(--radius) - 2px);--radius-lg:var(--radius);--god-gradient:linear-gradient(135deg, oklch(57% .19 266) 0%, oklch(100% 0 0) 50%, oklch(86% .12 90) 100%);--god-glow:0 0 24px oklch(57% .19 266/.28), 0 0 80px oklch(86% .12 90/.12);--rainbow-1:oklch(72% .145 266);--rainbow-2:oklch(74% .16 305);--rainbow-3:oklch(84% .1 185);--rainbow-4:oklch(80% .116 14);--rainbow-5:oklch(84% .13 90);--rainbow-speed:2s}}:root[data-theme=dark],.dark{--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20.5% 0 0);--card-foreground:oklch(98.5% 0 0);--popover:oklch(20.5% 0 0);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(92.2% 0 0);--primary-foreground:oklch(20.5% 0 0);--secondary:oklch(26.9% 0 0);--secondary-foreground:oklch(98.5% 0 0);--accent:oklch(26.9% 0 0);--accent-foreground:oklch(98.5% 0 0);--muted:oklch(26.9% 0 0);--muted-foreground:oklch(70.8% 0 0);--destructive:oklch(70.4% .191 22.216);--border:oklch(100% 0 0/.1);--input:oklch(100% 0 0/.15);--ring:oklch(55.6% 0 0);--chart-1:oklch(48.8% .243 264.376);--chart-2:oklch(69.6% .17 162.48);--chart-3:oklch(76.9% .188 70.08);--chart-4:oklch(62.7% .265 303.9);--chart-5:oklch(64.5% .246 16.439);--sidebar:oklch(20.5% 0 0);--sidebar-foreground:oklch(98.5% 0 0);--sidebar-primary:oklch(48.8% .243 264.376);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(26.9% 0 0);--sidebar-accent-foreground:oklch(98.5% 0 0);--sidebar-border:oklch(100% 0 0/.1);--sidebar-ring:oklch(55.6% 0 0);--syntax-plain:oklch(93.5% .01 266);--syntax-punctuation:oklch(65% .02 266);--syntax-keyword:oklch(78% .135 302);--syntax-property:oklch(83% .12 90);--syntax-string:oklch(80% .13 168);--syntax-comment:oklch(58% .02 266);--syntax-number:oklch(80% .12 224);--code-block:oklch(18.5% 0 0);--code-block-foreground:oklch(98.5% 0 0);--code-block-border:oklch(27% 0 0);--inline-code-bg:var(--muted);--inline-code-fg:var(--foreground);--inline-code-border:var(--border);--search-bg:var(--card);--search-fg:var(--muted-foreground);--search-border:var(--border);--search-kbd-bg:var(--muted);--search-kbd-fg:var(--muted-foreground);--search-placeholder:var(--muted-foreground);--search-highlight-bg:var(--primary);--search-highlight-fg:var(--primary-foreground);--theme-panel-bg:var(--card);--theme-panel-border:var(--border);--theme-panel-fg:var(--muted-foreground);--theme-panel-active-bg:var(--muted);--theme-panel-active-fg:var(--foreground);--shadow-2xs:0 1px 2px #0000001f;--shadow-xs:0 1px 3px #00000026;--shadow-sm:0 2px 6px #0003;--shadow:0 4px 12px #00000040;--shadow-md:0 8px 20px #0000004d;--shadow-lg:0 16px 32px #00000059;--shadow-xl:0 24px 48px #0006;--shadow-2xl:0 40px 80px #00000080;--color-bg:var(--background);--color-fg:var(--foreground);--color-border:var(--border);--color-primary:var(--primary);--color-primary-fg:var(--primary-foreground);--color-secondary-bg:var(--secondary);--color-secondary-fg:var(--secondary-foreground);--color-destructive:var(--destructive);--color-destructive-fg:oklch(100% 0 0);--glow-highlight:66, 108, 229;--color-primary-rgb:66, 108, 229;--radius-md:calc(var(--radius) - 2px);--radius-lg:var(--radius);--god-gradient:linear-gradient(135deg, oklch(57% .19 266) 0%, oklch(100% 0 0) 50%, oklch(86% .12 90) 100%);--god-glow:0 0 24px oklch(57% .19 266/.28), 0 0 80px oklch(86% .12 90/.12);--rainbow-1:oklch(72% .145 266);--rainbow-2:oklch(74% .16 305);--rainbow-3:oklch(84% .1 185);--rainbow-4:oklch(80% .116 14);--rainbow-5:oklch(84% .13 90);--rainbow-speed:2s}@media (color-gamut:p3){@media (prefers-color-scheme:dark){:root:not(.light){--syntax-keyword:oklch(78% .14 302);--rainbow-1:oklch(72% .15 266);--rainbow-4:oklch(80% .12 14)}}.dark{--syntax-keyword:oklch(78% .14 302);--rainbow-1:oklch(72% .15 266);--rainbow-4:oklch(80% .12 14)}}@keyframes magic-rainbow{0%{background-position:0%}to{background-position:200%}}@keyframes magic-input-indeterminate{0%{background-position:110%}to{background-position:-10%}}@keyframes magic-input-sweep{0%{background-size:0% 100%}to{background-size:100% 100%}}@keyframes magic-input-spin{to{transform:rotate(360deg)}}@keyframes shimmer-slide{to{transform:translate(calc(100cqw - 100%))}}@keyframes spin-around{0%{transform:translateZ(0)rotate(0)}15%,35%{transform:translateZ(0)rotate(90deg)}65%,85%{transform:translateZ(0)rotate(270deg)}to{transform:translateZ(0)rotate(360deg)}}@keyframes progress-fold-indeterminate{0%{transform:translate(-100%)}to{transform:translate(250%)}}@keyframes mask-button-in{0%{-webkit-mask-position:0 0;mask-position:0 0}to{-webkit-mask-position:100% 0;mask-position:100% 0}}@keyframes mask-button-out{0%{-webkit-mask-position:100% 0;mask-position:100% 0}to{-webkit-mask-position:0 0;mask-position:0 0}}@keyframes aurora-text{0%{background-position:0%}50%{background-position:100%}to{background-position:0%}}@keyframes marquee{0%{transform:translate(0)}to{transform:translateX(calc(-100% - var(--gap)))}}@keyframes marquee-vertical{0%{transform:translateY(0)}to{transform:translateY(calc(-100% - var(--gap)))}}@keyframes split-flap-fall{0%{transform:rotateX(0)}to{transform:rotateX(-90deg)}}@keyframes split-flap-rise{0%{transform:rotateX(90deg)}to{transform:rotateX(0)}}@keyframes blueprint-sweep{0%{transform:translate(-50%, -50%) rotate(var(--blueprint-angle,25deg));opacity:0}15%,85%{opacity:1}to{transform:translate(150%, 150%) rotate(var(--blueprint-angle,25deg));opacity:0}}@keyframes light-rays-sweep{0%{transform:rotate(calc(var(--rays-angle,0deg) - 6deg)) scale(1);opacity:calc(var(--rays-intensity,.6) * .7)}to{transform:rotate(calc(var(--rays-angle,0deg) + 6deg)) scale(1.08);opacity:var(--rays-intensity,.6)}}@keyframes voice-orb-spin{to{transform:rotate(360deg)}}@keyframes voice-orb-breathe{0%,to{transform:scale(1)}50%{transform:scale(1.04)}}@keyframes voice-orb-ring{0%{opacity:.6;transform:scale(.85)}to{opacity:0;transform:scale(1.4)}}@keyframes app-showcase-scroll{0%{transform:translateY(0)}to{transform:translateY(-50%)}}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}// godui source (MIT). npm i @tabler/icons-react clsx motion react tailwind-merge · Tailwind CSS v4
// ── cn.ts (https://github.com/LucasBassetti/godui/blob/1f632a76a346f09dc9fe066969906c6f98763e1e/cn.ts)
/*
MIT License
Copyright (c) 2026 Lucas Bassetti
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
canvas-confetti (ISC) was replaced with an original MIT helper by Incidental AI.
Sample photographs and brand marks were replaced with Incidental AI assets. Credit GodUI / Lucas Bassetti as attribution only; the name is not used for marketing.
*/
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...a){ return twMerge(clsx(a)); }
// ── demos/multi-button-demo.tsx (https://github.com/LucasBassetti/godui/blob/1f632a76a346f09dc9fe066969906c6f98763e1e/demos/multi-button-demo.tsx)
"use client";
import {
CompactMultiButton,
MultiButton,
type MultiButtonItem,
} from "@godui/lab";
import {
Archive,
Bookmark,
Copy,
Download,
EllipsisVertical,
Eye,
MessageSquare,
MoreHorizontal,
Share2,
Trash2,
} from "lucide-react";
import { type MouseEvent, useEffect, useRef, useState } from "react";
import { Segmented } from "@/components/docs-tabs";
const ACTION_DEFINITIONS = [
{ id: "review", icon: Eye, label: "Review" },
{ id: "download", icon: Download, label: "Download" },
{ id: "share", icon: Share2, label: "Share" },
{ id: "archive", icon: Archive, label: "Archive" },
{ id: "duplicate", icon: Copy, label: "Duplicate" },
{ id: "comment", icon: MessageSquare, label: "Comment" },
{ id: "save", icon: Bookmark, label: "Save" },
{ id: "delete", icon: Trash2, label: "Delete" },
] satisfies Omit<MultiButtonItem, "onClick">[];
export function MultiButtonDemo() {
const [selected, setSelected] = useState("review");
const [lastAction, setLastAction] = useState<string | null>(null);
const [treatment, setTreatment] = useState<"original" | "gooey">("original");
const [optionCount, setOptionCount] = useState(4);
const [isMobile, setIsMobile] = useState(false);
const demoRef = useRef<HTMLDivElement>(null);
const maxOptions = isMobile ? 4 : 8;
const gooey = treatment === "gooey";
const visibleDefinitions = ACTION_DEFINITIONS.slice(0, optionCount);
const items: MultiButtonItem[] = visibleDefinitions.map((item) => ({
...item,
onClick: () => setLastAction(item.label),
}));
const compactItems = items.map((item) => ({
...item,
onClick: (event: MouseEvent<HTMLButtonElement>) => {
item.onClick?.(event);
setSelected(item.id);
},
}));
const selectedLabel =
items.find((item) => item.id === selected)?.label ?? selected;
const changeOptionCount = (nextCount: number) => {
const boundedCount = Math.min(nextCount, maxOptions);
const nextDefinitions = ACTION_DEFINITIONS.slice(0, boundedCount);
setOptionCount(boundedCount);
setSelected((current) =>
nextDefinitions.some((item) => item.id === current)
? current
: (nextDefinitions[0]?.id ?? current),
);
};
useEffect(() => {
const view = demoRef.current?.ownerDocument.defaultView ?? window;
const mediaQuery = view.matchMedia("(max-width: 639px)");
const syncMobileLimit = () => {
const mobile = mediaQuery.matches;
setIsMobile(mobile);
if (!mobile) return;
setOptionCount((current) => Math.min(current, 4));
setSelected((current) =>
ACTION_DEFINITIONS.slice(0, 4).some((item) => item.id === current)
? current
: ACTION_DEFINITIONS[0].id,
);
};
syncMobileLimit();
mediaQuery.addEventListener("change", syncMobileLimit);
view.addEventListener("resize", syncMobileLimit);
return () => {
mediaQuery.removeEventListener("change", syncMobileLimit);
view.removeEventListener("resize", syncMobileLimit);
};
}, []);
return (
<div
ref={demoRef}
className="flex w-full max-w-[34rem] flex-col items-center gap-8 max-sm:gap-6"
>
<div className="flex w-full flex-col items-center gap-3 rounded-2xl border border-border/70 bg-card/60 p-6 shadow-xs max-sm:p-4">
<div className="flex items-center gap-2 text-xs text-muted-foreground">
<MoreHorizontal className="size-3.5" aria-hidden="true" />
Standard · hover, focus, or tap an action
</div>
<div className="no-scrollbar max-w-full overflow-x-auto py-1">
<MultiButton
items={items}
gooey={gooey}
highlightColor="var(--primary-foreground)"
size="lg"
variant="default"
/>
</div>
<span
className="min-h-4 text-xs text-muted-foreground"
aria-live="polite"
>
{lastAction ? `Last action: ${lastAction}` : "Choose an action"}
</span>
</div>
<div className="flex w-full flex-col items-center gap-3 rounded-2xl border border-border/70 bg-card/60 p-6 shadow-xs max-sm:p-4">
<span className="text-xs text-muted-foreground">
Compact · selected action: {selectedLabel}
</span>
<div className="no-scrollbar max-w-full overflow-x-auto py-1">
<CompactMultiButton
items={compactItems}
selectedId={selected}
restIcon={EllipsisVertical}
restAriaLabel="Open actions"
gooey={gooey}
highlightColor="var(--primary)"
size="lg"
variant="outline"
/>
</div>
</div>
<div className="flex flex-wrap items-center justify-center gap-3">
<label className="flex h-10 items-center gap-3 rounded-xl border border-border/70 bg-card/70 px-3 shadow-xs">
<span className="text-xs text-muted-foreground">Options</span>
<input
type="range"
min={2}
max={maxOptions}
step={1}
value={optionCount}
onChange={(event) => changeOptionCount(Number(event.target.value))}
className="w-28 cursor-pointer accent-primary"
aria-label="Number of Multi Button options"
/>
<output className="min-w-4 text-center font-medium text-xs tabular-nums">
{optionCount}
</output>
</label>
<Segmented
tabs={[
{ value: "original", label: "Original" },
{ value: "gooey", label: "Gooey" },
]}
value={treatment}
onChange={(value) =>
setTreatment(value === "gooey" ? "gooey" : "original")
}
semantics="radiogroup"
label="Multi Button motion treatment"
/>
</div>
</div>
);
}
// ── docs-tabs.tsx (https://github.com/LucasBassetti/godui/blob/1f632a76a346f09dc9fe066969906c6f98763e1e/docs-tabs.tsx)
/*
MIT License
Copyright (c) 2026 Lucas Bassetti
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
canvas-confetti (ISC) was replaced with an original MIT helper by Incidental AI.
Sample photographs and brand marks were replaced with Incidental AI assets. Credit GodUI / Lucas Bassetti as attribution only; the name is not used for marketing.
*/
import { cn } from "./cn";
export function Segmented({ tabs, value, onChange, className, iconOnly, label, semantics }) {
return (
<div role={semantics === "tabs" ? "tablist" : semantics === "radiogroup" ? "radiogroup" : undefined} aria-label={label} className={cn("flex gap-1 rounded-lg border border-border p-1", className)}>
{tabs.map((tab) => (
<button key={tab.value} type="button" onClick={() => onChange(tab.value)} className={cn("rounded-md px-3 py-1.5 text-sm", value === tab.value ? "bg-primary text-primary-foreground" : "text-muted-foreground")} aria-label={typeof tab.label === "string" ? tab.label : tab.value}>
{iconOnly ? tab.icon : (tab.icon ? <>{tab.icon}{tab.label}</> : tab.label)}
</button>
))}
</div>
);
}
export function DocsTabs(props) { return <Segmented {...props} semantics={props.semantics || "tabs"} />; }
export function PillTabs(props) { return <Segmented {...props} />; }
// ── multi-button/index.ts (https://github.com/LucasBassetti/godui/blob/1f632a76a346f09dc9fe066969906c6f98763e1e/multi-button/index.ts)
/*
MIT License
Copyright (c) 2026 Lucas Bassetti
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
canvas-confetti (ISC) was replaced with an original MIT helper by Incidental AI.
Sample photographs and brand marks were replaced with Incidental AI assets. Credit GodUI / Lucas Bassetti as attribution only; the name is not used for marketing.
*/
export {
CompactMultiButton,
type CompactMultiButtonProps,
MultiButton,
MultiButtonGroup,
type MultiButtonGroupProps,
type MultiButtonItem,
type MultiButtonProps,
type MultiButtonSize,
type MultiButtonVariant,
} from "./multi-button";
// ── multi-button/multi-button.tsx (https://github.com/LucasBassetti/godui/blob/1f632a76a346f09dc9fe066969906c6f98763e1e/multi-button/multi-button.tsx)
/*
MIT License
Copyright (c) 2026 Lucas Bassetti
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
canvas-confetti (ISC) was replaced with an original MIT helper by Incidental AI.
Sample photographs and brand marks were replaced with Incidental AI assets. Credit GodUI / Lucas Bassetti as attribution only; the name is not used for marketing.
*/
"use client";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
import * as React from "react";
export type MultiButtonVariant = "default" | "outline" | "secondary" | "ghost";
export type MultiButtonSize = "sm" | "md" | "lg";
export type MultiButtonItem = {
id: string;
icon: React.ElementType<{ className?: string }>;
label: React.ReactNode;
ariaLabel?: string;
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
disabled?: boolean;
className?: string;
/** Alias kept for callers that want a per-action hover treatment. */
hoverClassName?: string;
};
export type MultiButtonGroupProps = React.HTMLAttributes<HTMLDivElement> & {
children: React.ReactNode;
};
type MultiButtonRootProps = Omit<
React.HTMLAttributes<HTMLDivElement>,
| "onAnimationStart"
| "onAnimationEnd"
| "onClick"
| "onDrag"
| "onDragStart"
| "onDragEnd"
>;
type MultiButtonSharedProps = MultiButtonRootProps & {
items: MultiButtonItem[];
/** Optional items used to reserve the same expanded label width as another row. */
syncWidthTo?: MultiButtonItem[];
/** Optional CSS color or token reference used for a faint active-item tint. */
highlightColor?: string;
/** Use the more expressive SVG metaball treatment instead of the default pill morph. */
gooey?: boolean;
variant?: MultiButtonVariant;
size?: MultiButtonSize;
};
export type MultiButtonProps = MultiButtonSharedProps;
export type CompactMultiButtonProps = MultiButtonSharedProps & {
selectedId: string;
/** Keep the compact control icon-only when it opens. */
iconOnly?: boolean;
/** Optional independent icon shown while the compact control is at rest. */
restIcon?: MultiButtonItem["icon"];
/** Accessible label for the optional rest trigger. Defaults to "Open actions". */
restAriaLabel?: string;
};
type MultiButtonGroupContextValue = {
register: (id: string, labelWidth: number) => void;
unregister: (id: string) => void;
sharedLabelWidth: number;
};
const MultiButtonGroupContext = React.createContext<
MultiButtonGroupContextValue | undefined
>(undefined);
const SIZE_CONFIG: Record<
MultiButtonSize,
{ cell: number; icon: string; minHeight: string; text: string }
> = {
sm: { cell: 40, icon: "size-3.5", minHeight: "h-10", text: "text-xs" },
md: { cell: 40, icon: "size-4", minHeight: "h-10", text: "text-sm" },
lg: {
cell: 40,
icon: "size-[18px]",
minHeight: "h-10",
text: "text-sm",
},
};
const VARIANT_CLASSES: Record<MultiButtonVariant, string> = {
default:
"bg-primary text-primary-foreground shadow-sm ring-1 ring-primary/20",
outline:
"bg-background text-foreground shadow-xs ring-1 ring-inset ring-border/80",
secondary: "bg-secondary text-secondary-foreground shadow-xs",
ghost: "bg-muted/50 text-foreground ring-1 ring-border/60",
};
const ITEM_HOVER_CLASSES: Record<MultiButtonVariant, string> = {
default: "hover:bg-primary-foreground/10 active:bg-primary-foreground/20",
outline: "hover:bg-accent hover:text-accent-foreground active:bg-accent/80",
secondary:
"hover:bg-secondary-foreground/10 active:bg-secondary-foreground/20",
ghost: "hover:bg-accent hover:text-accent-foreground active:bg-accent/80",
};
const DIVIDER_CLASSES: Record<MultiButtonVariant, string> = {
default: "bg-primary-foreground/20",
outline: "bg-border/70",
secondary: "bg-secondary-foreground/15",
ghost: "bg-border/70",
};
const GOOEY_BLOB_FILLS: Record<MultiButtonVariant, string> = {
default: "var(--primary)",
outline: "var(--background)",
secondary: "var(--secondary)",
ghost: "color-mix(in oklab, var(--muted) 50%, transparent)",
};
const GOOEY_TEXT_CLASSES: Record<MultiButtonVariant, string> = {
default: "text-primary-foreground",
outline: "text-foreground",
secondary: "text-secondary-foreground",
ghost: "text-foreground",
};
const LABEL_SPRING = {
type: "spring",
stiffness: 520,
damping: 32,
} as const;
const CONTEXTUAL_ICON_TRANSITION = {
type: "spring",
duration: 0.3,
bounce: 0,
} as const;
const COMPACT_EXPAND_DURATION_MS = 200;
const GOOEY_BOUNCE_DURATION_MS = 300;
const GOOEY_BOUNCE_TRANSITION = {
duration: GOOEY_BOUNCE_DURATION_MS / 1000,
ease: [0.3, 0.7, 0.4, 1.5],
} as const;
const GOOEY_CLOSE_TRANSITION = {
duration: COMPACT_EXPAND_DURATION_MS / 1000,
ease: [0.3, 0.7, 0.4, 1],
} as const;
const GOOEY_RAIL_TRANSITION_CLASSES = {
expanded: "[transition:width_300ms_cubic-bezier(0.3,0.7,0.4,1.5)]",
collapsed: "[transition:width_200ms_cubic-bezier(0.3,0.7,0.4,1)]",
} as const;
const GOOEY_ITEM_TRANSITION_CLASSES = {
expanded:
"[transition:width_300ms_cubic-bezier(0.3,0.7,0.4,1.5),background-color_150ms_ease,color_150ms_ease,scale_120ms_ease]",
collapsed:
"[transition:width_200ms_cubic-bezier(0.3,0.7,0.4,1),background-color_150ms_ease,color_150ms_ease,scale_120ms_ease]",
} as const;
const GOOEY_ICON_TRANSITION_CLASSES = {
expanded: "[transition:transform_300ms_cubic-bezier(0.3,0.7,0.4,1.5)]",
collapsed: "[transition:transform_200ms_cubic-bezier(0.3,0.7,0.4,1)]",
} as const;
const GOOEY_DIVIDER_TRANSITION_CLASSES = {
expanded:
"[transition:width_300ms_cubic-bezier(0.3,0.7,0.4,1.5),opacity_150ms_ease]",
collapsed:
"[transition:width_200ms_cubic-bezier(0.3,0.7,0.4,1),opacity_150ms_ease]",
} as const;
function gooeyPhase(expanded: boolean) {
return expanded ? "expanded" : "collapsed";
}
function gooeyMotionTransition(reduceMotion: boolean, expanded: boolean) {
if (reduceMotion) return { duration: 0 } as const;
return expanded ? GOOEY_BOUNCE_TRANSITION : GOOEY_CLOSE_TRANSITION;
}
function railClassName({
className,
compact,
expanded,
gooey,
minHeight,
variant,
}: {
className?: string;
compact: boolean;
expanded: boolean;
gooey: boolean;
minHeight: string;
variant: MultiButtonVariant;
}) {
const phase = gooeyPhase(expanded);
const surface = gooey
? `overflow-visible ${GOOEY_TEXT_CLASSES[variant]}`
: `overflow-hidden ${VARIANT_CLASSES[variant]}`;
const widthTransition = compact
? gooey
? GOOEY_RAIL_TRANSITION_CLASSES[phase]
: "[transition:width_200ms_ease-out]"
: "";
return `relative inline-flex items-stretch rounded-full ${minHeight} ${surface} ${widthTransition} motion-reduce:[transition:none] ${className ?? ""}`;
}
function useMultiButtonInteractions() {
const reduceMotion = Boolean(useReducedMotion());
const filterId = React.useId().replace(/:/g, "");
const [hoveredId, setHoveredId] = React.useState<string | null>(null);
const [touchExpandedId, setTouchExpandedId] = React.useState<string | null>(
null,
);
const containerRef = React.useRef<HTMLDivElement>(null);
return {
containerRef,
filterId,
hoveredId,
reduceMotion,
setHoveredId,
setTouchExpandedId,
touchExpandedId,
};
}
function useOutsidePointerDown(
active: boolean,
containerRef: React.RefObject<HTMLDivElement | null>,
onOutside: () => void,
) {
React.useEffect(() => {
if (!active) return;
// The rail may be portaled into a preview iframe, whose document is
// different from the page document running this component.
const ownerDocument = containerRef.current?.ownerDocument ?? document;
const handlePointerDown = (event: PointerEvent) => {
if (!containerRef.current?.contains(event.target as Node)) onOutside();
};
ownerDocument.addEventListener("pointerdown", handlePointerDown);
return () =>
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
}, [active, containerRef, onOutside]);
}
function labelText(label: React.ReactNode) {
return typeof label === "string" || typeof label === "number"
? label.toString()
: "";
}
function estimateLabelWidth(label: React.ReactNode, size: MultiButtonSize) {
const textWidth = labelText(label).length * (size === "sm" ? 6.5 : 7.5);
return Math.ceil(textWidth) + (size === "lg" ? 10 : size === "md" ? 8 : 6);
}
function maxLabelWidth(items: MultiButtonItem[], size: MultiButtonSize) {
return items.reduce(
(max, item) => Math.max(max, estimateLabelWidth(item.label, size)),
0,
);
}
function estimatedLabelWidths(items: MultiButtonItem[], size: MultiButtonSize) {
return Object.fromEntries(
items.map((item) => [item.id, estimateLabelWidth(item.label, size)]),
);
}
function equalLabelWidths(
current: Record<string, number>,
next: Record<string, number>,
) {
const currentIds = Object.keys(current);
const nextIds = Object.keys(next);
return (
currentIds.length === nextIds.length &&
nextIds.every((id) => current[id] === next[id])
);
}
function measuredLabelWidth(
element: HTMLElement | undefined,
fallback: number,
) {
if (!element) return fallback;
const style = getComputedStyle(element);
const marginLeft = Number.parseFloat(style.marginLeft) || 0;
const marginRight = Number.parseFloat(style.marginRight) || 0;
const measured = Math.ceil(
element.getBoundingClientRect().width + marginLeft + marginRight,
);
return measured > 0 ? measured : fallback;
}
function itemAriaLabel(item: MultiButtonItem) {
return item.ariaLabel ?? (labelText(item.label) || item.id);
}
function useLabelWidths(
items: MultiButtonItem[],
syncWidthTo: MultiButtonItem[] | undefined,
size: MultiButtonSize,
) {
const group = React.useContext(MultiButtonGroupContext);
const instanceId = React.useId();
const reserveItems = syncWidthTo ?? items;
const itemEstimates = React.useMemo(
() => estimatedLabelWidths(items, size),
[items, size],
);
const estimatedReserveWidth = React.useMemo(
() => maxLabelWidth(reserveItems, size),
[reserveItems, size],
);
const [labelWidths, setLabelWidths] =
React.useState<Record<string, number>>(itemEstimates);
const [ownReservedWidth, setOwnReservedWidth] = React.useState(
estimatedReserveWidth,
);
const measurementRef = React.useRef<HTMLDivElement>(null);
const register = group?.register;
const unregister = group?.unregister;
const measureLabels = React.useCallback(() => {
const itemLabels = measurementRef.current?.querySelectorAll<HTMLElement>(
'[data-slot="multi-button-item-label-measure"]',
);
const nextLabelWidths = Object.fromEntries(
items.map((item, index) => [
item.id,
measuredLabelWidth(itemLabels?.[index], itemEstimates[item.id] ?? 0),
]),
);
setLabelWidths((current) =>
equalLabelWidths(current, nextLabelWidths) ? current : nextLabelWidths,
);
const reserveLabels = measurementRef.current?.querySelectorAll<HTMLElement>(
'[data-slot="multi-button-reserve-label-measure"]',
);
const measuredReserveWidth = reserveItems.reduce(
(largest, item, index) =>
Math.max(
largest,
measuredLabelWidth(
reserveLabels?.[index],
estimateLabelWidth(item.label, size),
),
),
0,
);
setOwnReservedWidth((current) =>
current === measuredReserveWidth ? current : measuredReserveWidth,
);
}, [itemEstimates, items, reserveItems, size]);
React.useLayoutEffect(() => {
const measurementNode = measurementRef.current;
if (!measurementNode) return;
let active = true;
const measure = () => {
if (active) measureLabels();
};
measure();
const observer =
typeof ResizeObserver === "undefined"
? undefined
: new ResizeObserver(measure);
const labels = measurementNode.querySelectorAll<HTMLElement>(
'[data-slot$="-label-measure"]',
);
labels.forEach((label) => {
observer?.observe(label);
});
void document.fonts?.ready.then(measure);
return () => {
active = false;
observer?.disconnect();
};
}, [measureLabels]);
React.useLayoutEffect(() => {
if (!register || !unregister) return;
register(instanceId, ownReservedWidth);
return () => unregister(instanceId);
}, [instanceId, ownReservedWidth, register, unregister]);
return {
labelWidths,
reservedLabelWidth: group
? Math.max(group.sharedLabelWidth, ownReservedWidth)
: ownReservedWidth,
measurementRef,
reserveItems,
};
}
function MultiButtonLabelMeasurement({
items,
reserveItems,
measurementRef,
size,
}: {
items: MultiButtonItem[];
reserveItems: MultiButtonItem[];
measurementRef: React.RefObject<HTMLDivElement | null>;
size: MultiButtonSize;
}) {
return (
<div
ref={measurementRef}
aria-hidden="true"
className="pointer-events-none invisible absolute top-0 left-0 flex h-0 w-0 overflow-hidden"
>
{items.map((item) => (
<span
key={`item-${item.id}`}
data-slot="multi-button-item-label-measure"
className={`-ml-1 shrink-0 whitespace-nowrap pr-2 font-medium leading-none ${SIZE_CONFIG[size].text}`}
>
{item.label}
</span>
))}
{reserveItems.map((item) => (
<span
key={`reserve-${item.id}`}
data-slot="multi-button-reserve-label-measure"
className={`-ml-1 shrink-0 whitespace-nowrap pr-2 font-medium leading-none ${SIZE_CONFIG[size].text}`}
>
{item.label}
</span>
))}
</div>
);
}
function actionWidth(
item: MultiButtonItem,
activeId: string | null,
itemCount: number,
cellWidth: number,
labelWidths: Record<string, number>,
reservedLabelWidth: number,
) {
if (activeId === null) {
return itemCount > 0
? cellWidth + reservedLabelWidth / itemCount
: cellWidth;
}
const activeLabelWidth = labelWidths[activeId] ?? reservedLabelWidth;
if (item.id === activeId) return cellWidth + activeLabelWidth;
const remainingLabelSpace = Math.max(
0,
reservedLabelWidth - activeLabelWidth,
);
return itemCount > 1
? cellWidth + remainingLabelSpace / (itemCount - 1)
: cellWidth;
}
type MultiButtonBlobGeometry = {
item: MultiButtonItem;
width: number;
x: number;
};
function useMultiButtonLayout({
activeId,
items,
reserveLabelSpace = true,
size,
syncWidthTo,
}: {
activeId: string | null;
items: MultiButtonItem[];
reserveLabelSpace?: boolean;
size: MultiButtonSize;
syncWidthTo?: MultiButtonItem[];
}) {
const cfg = SIZE_CONFIG[size];
const { labelWidths, reservedLabelWidth, measurementRef, reserveItems } =
useLabelWidths(items, syncWidthTo, size);
const effectiveLabelWidth = reserveLabelSpace ? reservedLabelWidth : 0;
const dividerWidth = Math.max(0, items.length - 1);
const expandedWidth =
items.length > 0
? items.length * cfg.cell + effectiveLabelWidth + dividerWidth
: cfg.cell;
const itemWidths = items.map((item) =>
actionWidth(
item,
activeId,
items.length,
cfg.cell,
labelWidths,
effectiveLabelWidth,
),
);
let blobX = 0;
const blobGeometries = items.map((item, index) => {
const geometry = {
item,
width: itemWidths[index] ?? cfg.cell,
x: blobX,
};
blobX += geometry.width + (index < items.length - 1 ? 1 : 0);
return geometry;
});
return {
blobGeometries,
cfg,
expandedWidth,
itemWidths,
measurementRef,
reserveItems,
};
}
function MultiButtonBlobLayer({
activeId,
cellWidth,
expanded,
filterId,
geometries,
highlightColor,
reduceMotion,
selectedId,
variant,
}: {
activeId: string | null;
cellWidth: number;
expanded: boolean;
filterId: string;
geometries: MultiButtonBlobGeometry[];
highlightColor?: string;
reduceMotion: boolean;
selectedId: string | undefined;
variant: MultiButtonVariant;
}) {
const baseFill = GOOEY_BLOB_FILLS[variant];
return (
<svg
data-slot="multi-button-blob"
aria-hidden="true"
className="pointer-events-none absolute top-0 left-0 z-base drop-shadow-sm"
style={{ overflow: "visible" }}
width="100%"
height={cellWidth}
>
<defs>
<filter
id={filterId}
x="-100%"
y="-400%"
width="300%"
height="900%"
colorInterpolationFilters="sRGB"
>
<feGaussianBlur in="SourceGraphic" stdDeviation="6" result="blur" />
<feColorMatrix
in="blur"
mode="matrix"
values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10"
/>
</filter>
</defs>
<g filter={reduceMotion ? undefined : `url(#${filterId})`}>
{geometries.map(({ item, width, x }) => {
const selected = item.id === selectedId;
const active = item.id === activeId;
const fill =
active && highlightColor
? `color-mix(in oklch, ${baseFill} 86%, ${highlightColor})`
: baseFill;
return (
<motion.rect
key={item.id}
x={0}
y={0}
height={cellWidth}
rx={cellWidth / 2}
fill={fill}
style={{
transformBox: "fill-box",
transformOrigin: "center",
}}
initial={false}
animate={
expanded
? { x, width, scale: 1, opacity: 1 }
: selected
? { x: 0, width: cellWidth, scale: 1, opacity: 1 }
: {
x: 0,
width: cellWidth,
scale: 0.2,
opacity: 0,
}
}
transition={gooeyMotionTransition(reduceMotion, expanded)}
/>
);
})}
</g>
</svg>
);
}
function labelMotion(reduceMotion: boolean) {
return {
initial: reduceMotion
? false
: { opacity: 0, scale: 0.25, filter: "blur(4px)" },
animate: { opacity: 1, scale: 1, filter: "blur(0px)" },
exit: reduceMotion
? undefined
: { opacity: 0, scale: 0.25, filter: "blur(4px)" },
transition: reduceMotion
? { duration: 0 }
: {
opacity: LABEL_SPRING,
scale: LABEL_SPRING,
filter: { duration: 0.15, ease: "easeOut" },
},
} as const;
}
type MultiButtonLabelProps = {
item: MultiButtonItem;
reduceMotion: boolean;
textClass: string;
};
const MultiButtonLabel = React.forwardRef<
HTMLSpanElement,
MultiButtonLabelProps
>(({ item, reduceMotion, textClass }, ref) => (
<motion.span
ref={ref}
{...labelMotion(reduceMotion)}
className={`relative z-raised -ml-1 shrink-0 whitespace-nowrap pr-2 font-medium leading-none ${textClass}`}
>
{item.label}
</motion.span>
));
MultiButtonLabel.displayName = "MultiButtonLabel";
type MultiButtonItemButtonProps = {
item: MultiButtonItem;
active: boolean;
accessible?: boolean;
ariaLabel?: string;
disclosureExpanded?: boolean;
disabled: boolean;
highlighted: boolean;
gooey?: boolean;
gooeyExpanded?: boolean;
transparent?: boolean;
size: MultiButtonSize;
variant: MultiButtonVariant;
width: number;
iconOffset: number;
reduceMotion: boolean;
restIcon?: MultiButtonItem["icon"];
showRestIcon?: boolean;
visible?: boolean;
onTouchAction: (
event: React.PointerEvent<HTMLButtonElement>,
id: string,
) => void;
onHover: (id: string | null) => void;
onAction?: (event: React.MouseEvent<HTMLButtonElement>) => void;
};
type MultiButtonItemIconProps = {
actionIcon: MultiButtonItem["icon"];
gooey: boolean;
gooeyExpanded: boolean;
iconClassName: string;
iconOffset: number;
laneWidth: number;
reduceMotion: boolean;
restIcon?: MultiButtonItem["icon"];
showRestIcon: boolean;
};
function MultiButtonItemIcon({
actionIcon: ActionIcon,
gooey,
gooeyExpanded,
iconClassName,
iconOffset,
laneWidth,
reduceMotion,
restIcon: RestIcon,
showRestIcon,
}: MultiButtonItemIconProps) {
const phase = gooeyPhase(gooeyExpanded);
const iconTransition = reduceMotion
? ({ duration: 0 } as const)
: CONTEXTUAL_ICON_TRANSITION;
const visibleState = { opacity: 1, scale: 1, filter: "blur(0px)" };
const hiddenState = { opacity: 0, scale: 0.25, filter: "blur(4px)" };
return (
<span
data-slot="multi-button-icon"
className={`relative z-raised flex h-full shrink-0 items-center justify-center motion-reduce:[transition:none] ${gooey ? GOOEY_ICON_TRANSITION_CLASSES[phase] : "[transition:transform_200ms_ease-out]"}`}
style={{
width: `${laneWidth}px`,
transform: `translateX(${iconOffset}px)`,
}}
aria-hidden="true"
>
{RestIcon ? (
<>
<motion.span
data-slot="multi-button-action-icon"
className="absolute inset-0 flex items-center justify-center"
initial={false}
animate={showRestIcon ? hiddenState : visibleState}
transition={iconTransition}
>
<ActionIcon className={iconClassName} />
</motion.span>
<motion.span
data-slot="multi-button-rest-icon"
className="absolute inset-0 flex items-center justify-center"
initial={false}
animate={showRestIcon ? visibleState : hiddenState}
transition={iconTransition}
>
<RestIcon className={iconClassName} />
</motion.span>
</>
) : (
<ActionIcon className={iconClassName} />
)}
</span>
);
}
function MultiButtonItemButton({
item,
active,
accessible = true,
ariaLabel,
disclosureExpanded,
disabled,
highlighted,
gooey = false,
gooeyExpanded = true,
transparent = false,
size,
variant,
width,
iconOffset,
reduceMotion,
restIcon,
showRestIcon = false,
visible = true,
onTouchAction,
onHover,
onAction,
}: MultiButtonItemButtonProps) {
const cfg = SIZE_CONFIG[size];
const phase = gooeyPhase(gooeyExpanded);
return (
<motion.button
type="button"
data-state={active ? "open" : "closed"}
data-multi-button-item-id={item.id}
aria-label={ariaLabel ?? itemAriaLabel(item)}
aria-expanded={disclosureExpanded}
aria-hidden={accessible ? undefined : true}
tabIndex={accessible ? undefined : -1}
disabled={disabled}
onClick={(event) => {
if (item.disabled) return;
item.onClick?.(event);
onAction?.(event);
}}
onPointerDown={(event) => onTouchAction(event, item.id)}
onMouseEnter={() => onHover(item.id)}
onMouseLeave={() => onHover(null)}
onFocus={() => onHover(item.id)}
onBlur={() => onHover(null)}
initial={false}
animate={
gooey
? {
opacity: visible ? 1 : 0,
scale: visible ? 1 : 0.4,
}
: undefined
}
transition={
gooey ? gooeyMotionTransition(reduceMotion, gooeyExpanded) : undefined
}
style={{ width: `${width}px` }}
className={`relative isolate flex shrink-0 cursor-pointer items-center justify-start overflow-hidden ${cfg.minHeight} focus:outline-none focus-visible:z-raised focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:[transition:none] ${accessible ? "" : "pointer-events-none"} ${gooey ? GOOEY_ITEM_TRANSITION_CLASSES[phase] : "[transition:width_200ms_ease-out,background-color_150ms_ease,color_150ms_ease,scale_120ms_ease]"} ${reduceMotion ? "" : "active:scale-[0.96]"} ${transparent ? "" : ITEM_HOVER_CLASSES[variant]} ${item.hoverClassName ?? ""} ${item.className ?? ""}`}
>
<span
data-slot="multi-button-highlight"
aria-hidden="true"
className={`pointer-events-none absolute inset-0 z-base bg-[var(--multi-button-highlight)] [transition:opacity_150ms_ease] motion-reduce:[transition:none] ${highlighted ? "opacity-[0.14]" : "opacity-0"}`}
/>
<MultiButtonItemIcon
actionIcon={item.icon}
gooey={gooey}
gooeyExpanded={gooeyExpanded}
iconClassName={cfg.icon}
iconOffset={iconOffset}
laneWidth={cfg.cell}
reduceMotion={reduceMotion}
restIcon={restIcon}
showRestIcon={showRestIcon}
/>
<AnimatePresence initial={false} mode="popLayout">
{active && (
<MultiButtonLabel
key={item.id}
item={item}
reduceMotion={reduceMotion}
textClass={cfg.text}
/>
)}
</AnimatePresence>
</motion.button>
);
}
function MultiButtonDivider({
activeId,
compact,
expanded,
gooey,
variant,
}: {
activeId: string | null;
compact: boolean;
expanded: boolean;
gooey: boolean;
variant: MultiButtonVariant;
}) {
if (!compact) {
return (
<span
aria-hidden="true"
className={`my-2 w-px shrink-0 transition-opacity duration-150 motion-reduce:[transition:none] ${DIVIDER_CLASSES[variant]} ${activeId ? "opacity-0" : "opacity-100"}`}
/>
);
}
const phase = gooeyPhase(expanded);
return (
<span
aria-hidden="true"
style={{
width: `${expanded ? 1 : 0}px`,
opacity: expanded && activeId === null ? 1 : 0,
}}
className={`my-2 shrink-0 motion-reduce:[transition:none] ${gooey ? GOOEY_DIVIDER_TRANSITION_CLASSES[phase] : "[transition:width_200ms_ease-out,opacity_200ms_ease-out]"} ${DIVIDER_CLASSES[variant]}`}
/>
);
}
type MultiButtonItemsProps = {
activeId: string | null;
compact: boolean;
expanded: boolean;
gooey: boolean;
highlightColor?: string;
itemWidths: number[];
interactionReady: boolean;
items: MultiButtonItem[];
onAction?: (event: React.MouseEvent<HTMLButtonElement>) => void;
onHover: (id: string | null) => void;
onTouchAction: (
event: React.PointerEvent<HTMLButtonElement>,
id: string,
) => void;
reduceMotion: boolean;
restAriaLabel?: string;
restIcon?: MultiButtonItem["icon"];
selectedId?: string;
size: MultiButtonSize;
variant: MultiButtonVariant;
};
function MultiButtonItems({
activeId,
compact,
expanded,
gooey,
highlightColor,
itemWidths,
interactionReady,
items,
onAction,
onHover,
onTouchAction,
reduceMotion,
restAriaLabel,
restIcon,
selectedId,
size,
variant,
}: MultiButtonItemsProps) {
const cfg = SIZE_CONFIG[size];
return items.map((item, index) => {
const active = activeId === item.id;
const selected = selectedId === item.id;
const collapsedSelectedTrigger = compact && selected && !expanded;
const width =
compact && !expanded
? selected
? cfg.cell
: 0
: (itemWidths[index] ?? cfg.cell);
const iconOffset =
compact && !expanded
? 0
: active
? 0
: Math.max(0, (width - cfg.cell) / 2);
return (
<React.Fragment key={item.id}>
{index > 0 && (
<MultiButtonDivider
activeId={activeId}
compact={compact}
expanded={expanded}
gooey={gooey}
variant={variant}
/>
)}
<MultiButtonItemButton
item={item}
active={active}
accessible={!compact || interactionReady || selected}
ariaLabel={
collapsedSelectedTrigger
? (restAriaLabel ?? (restIcon ? "Open actions" : undefined))
: undefined
}
disclosureExpanded={compact && selected ? expanded : undefined}
disabled={Boolean(item.disabled && !collapsedSelectedTrigger)}
highlighted={!gooey && Boolean(highlightColor) && active}
gooey={gooey}
gooeyExpanded={expanded}
transparent={gooey}
size={size}
variant={variant}
width={width}
iconOffset={iconOffset}
reduceMotion={reduceMotion}
restIcon={compact && selected ? restIcon : undefined}
showRestIcon={compact && selected && Boolean(restIcon) && !expanded}
visible={!compact || expanded || selected}
onTouchAction={onTouchAction}
onHover={onHover}
onAction={onAction}
/>
</React.Fragment>
);
});
}
type MultiButtonRailContentProps = MultiButtonItemsProps & {
blobGeometries: MultiButtonBlobGeometry[];
cellWidth: number;
expandedWidth: number;
filterId: string;
measurementRef: React.RefObject<HTMLDivElement | null>;
reserveItems: MultiButtonItem[];
};
function MultiButtonRailContent({
activeId,
blobGeometries,
cellWidth,
compact,
expanded,
filterId,
gooey,
highlightColor,
itemWidths,
interactionReady,
items,
measurementRef,
onAction,
onHover,
onTouchAction,
reduceMotion,
restAriaLabel,
restIcon,
reserveItems,
selectedId,
size,
variant,
}: MultiButtonRailContentProps) {
return (
<>
{gooey && (
<MultiButtonBlobLayer
activeId={activeId}
cellWidth={cellWidth}
expanded={expanded}
filterId={filterId}
geometries={blobGeometries}
highlightColor={highlightColor}
reduceMotion={reduceMotion}
selectedId={selectedId}
variant={variant}
/>
)}
<MultiButtonLabelMeasurement
items={items}
reserveItems={reserveItems}
measurementRef={measurementRef}
size={size}
/>
<MultiButtonItems
activeId={activeId}
compact={compact}
expanded={expanded}
gooey={gooey}
highlightColor={highlightColor}
itemWidths={itemWidths}
interactionReady={interactionReady}
items={items}
onAction={onAction}
onHover={onHover}
onTouchAction={onTouchAction}
reduceMotion={reduceMotion}
restAriaLabel={restAriaLabel}
restIcon={restIcon}
selectedId={selectedId}
size={size}
variant={variant}
/>
</>
);
}
type MultiButtonRailProps = MultiButtonRailContentProps & {
className?: string;
containerRef: React.RefObject<HTMLDivElement | null>;
containerWidth: number;
forwardedRef: React.ForwardedRef<HTMLDivElement>;
rootProps: MultiButtonRootProps;
slot: "multi-button" | "compact-multi-button";
style?: React.CSSProperties;
};
function MultiButtonRail({
className,
compact,
containerRef,
containerWidth,
expanded,
forwardedRef,
gooey,
highlightColor,
rootProps,
size,
slot,
style,
variant,
...contentProps
}: MultiButtonRailProps) {
const cfg = SIZE_CONFIG[size];
return (
<motion.div
ref={(node) => {
containerRef.current = node;
if (typeof forwardedRef === "function") forwardedRef(node);
else if (forwardedRef) forwardedRef.current = node;
}}
data-slot={slot}
role="group"
aria-expanded={compact ? expanded : undefined}
style={
{
...style,
width: `${containerWidth}px`,
"--multi-button-highlight": highlightColor,
} as React.CSSProperties
}
className={railClassName({
className,
compact,
expanded,
gooey,
minHeight: cfg.minHeight,
variant,
})}
{...rootProps}
>
<MultiButtonRailContent
{...contentProps}
compact={compact}
expanded={expanded}
gooey={gooey}
highlightColor={highlightColor}
size={size}
variant={variant}
/>
</motion.div>
);
}
const MultiButtonGroup = React.forwardRef<
HTMLDivElement,
MultiButtonGroupProps
>(({ children, className, ...props }, ref) => {
const [registry, setRegistry] = React.useState<Record<string, number>>({});
const register = React.useCallback((id: string, width: number) => {
setRegistry((current) =>
current[id] === width ? current : { ...current, [id]: width },
);
}, []);
const unregister = React.useCallback((id: string) => {
setRegistry((current) => {
if (!(id in current)) return current;
const next = { ...current };
delete next[id];
return next;
});
}, []);
const sharedLabelWidth = Math.max(0, ...Object.values(registry));
const context = React.useMemo(
() => ({ register, unregister, sharedLabelWidth }),
[register, unregister, sharedLabelWidth],
);
return (
<MultiButtonGroupContext.Provider value={context}>
<div
ref={ref}
data-slot="multi-button-group"
className={`contents ${className ?? ""}`}
{...props}
>
{children}
</div>
</MultiButtonGroupContext.Provider>
);
});
MultiButtonGroup.displayName = "MultiButtonGroup";
const MultiButton = React.forwardRef<HTMLDivElement, MultiButtonProps>(
(
{
items,
syncWidthTo,
highlightColor,
gooey = false,
variant = "default",
size = "md",
className,
style,
...props
},
ref,
) => {
const {
containerRef,
filterId,
hoveredId,
reduceMotion,
setHoveredId,
setTouchExpandedId,
touchExpandedId,
} = useMultiButtonInteractions();
const activeId = hoveredId ?? touchExpandedId;
const {
blobGeometries,
cfg,
expandedWidth,
itemWidths,
measurementRef,
reserveItems,
} = useMultiButtonLayout({ activeId, items, size, syncWidthTo });
const collapseTouchAction = React.useCallback(
() => setTouchExpandedId(null),
[setTouchExpandedId],
);
useOutsidePointerDown(
Boolean(touchExpandedId),
containerRef,
collapseTouchAction,
);
const onTouchAction = (
event: React.PointerEvent<HTMLButtonElement>,
id: string,
) => {
if (event.pointerType !== "touch") return;
if (touchExpandedId !== id) {
setTouchExpandedId(id);
}
};
return (
<MultiButtonRail
activeId={activeId}
blobGeometries={blobGeometries}
cellWidth={cfg.cell}
className={className}
compact={false}
containerRef={containerRef}
containerWidth={expandedWidth}
expanded
expandedWidth={expandedWidth}
filterId={filterId}
forwardedRef={ref}
gooey={gooey}
highlightColor={highlightColor}
itemWidths={itemWidths}
interactionReady
items={items}
measurementRef={measurementRef}
onHover={setHoveredId}
onTouchAction={onTouchAction}
reduceMotion={reduceMotion}
reserveItems={reserveItems}
rootProps={props}
size={size}
slot="multi-button"
style={style}
variant={variant}
/>
);
},
);
MultiButton.displayName = "MultiButton";
const CompactMultiButton = React.forwardRef<
HTMLDivElement,
CompactMultiButtonProps
>(
(
{
items,
selectedId,
iconOnly = false,
restIcon,
restAriaLabel,
syncWidthTo,
highlightColor,
gooey = false,
variant = "default",
size = "md",
className,
style,
onMouseEnter: onMouseEnterProp,
onMouseLeave: onMouseLeaveProp,
onFocusCapture: onFocusCaptureProp,
onBlurCapture: onBlurCaptureProp,
onTransitionEnd: onTransitionEndProp,
...rootProps
},
ref,
) => {
const {
containerRef,
filterId,
hoveredId,
reduceMotion,
setHoveredId,
setTouchExpandedId,
touchExpandedId,
} = useMultiButtonInteractions();
const [mouseExpanded, setMouseExpanded] = React.useState(false);
const [touchExpanded, setTouchExpanded] = React.useState(false);
const [focusExpanded, setFocusExpanded] = React.useState(false);
const [compactRailReady, setCompactRailReady] = React.useState(false);
const focusRestoreFrameRef = React.useRef<number | null>(null);
const suppressFocusExpansionRef = React.useRef(false);
const selectedItem =
items.find((item) => item.id === selectedId) ?? items[0];
const isExpanded = mouseExpanded || touchExpanded || focusExpanded;
const activeId =
iconOnly || !isExpanded || !compactRailReady
? null
: (hoveredId ?? touchExpandedId);
const {
blobGeometries,
cfg,
expandedWidth,
itemWidths,
measurementRef,
reserveItems,
} = useMultiButtonLayout({
activeId,
items,
reserveLabelSpace: !iconOnly,
size,
syncWidthTo,
});
const containerWidth = isExpanded ? expandedWidth : cfg.cell;
const expansionStateRef = React.useRef({
expanded: isExpanded,
expandedWidth,
});
React.useLayoutEffect(() => {
expansionStateRef.current = { expanded: isExpanded, expandedWidth };
if (!isExpanded) {
setCompactRailReady(false);
return;
}
if (reduceMotion) {
setCompactRailReady(true);
return;
}
setCompactRailReady(expandedWidth === cfg.cell);
}, [cfg.cell, expandedWidth, isExpanded, reduceMotion]);
React.useEffect(
() => () => {
if (focusRestoreFrameRef.current !== null) {
cancelAnimationFrame(focusRestoreFrameRef.current);
}
},
[],
);
const handleRailTransitionEnd = React.useCallback(
(event: React.TransitionEvent<HTMLDivElement>) => {
if (
event.target !== event.currentTarget ||
(event.propertyName && event.propertyName !== "width") ||
reduceMotion
) {
return;
}
const expected = expansionStateRef.current;
const inlineWidth = Number.parseFloat(event.currentTarget.style.width);
const renderedWidth = event.currentTarget.getBoundingClientRect().width;
if (
!expected.expanded ||
Math.abs(inlineWidth - expected.expandedWidth) > 0.5 ||
(renderedWidth > 0 &&
Math.abs(renderedWidth - expected.expandedWidth) > 1)
) {
return;
}
setCompactRailReady(true);
},
[reduceMotion],
);
const collapseTouchAction = React.useCallback(() => {
setTouchExpanded(false);
setTouchExpandedId(null);
}, [setTouchExpandedId]);
useOutsidePointerDown(touchExpanded, containerRef, collapseTouchAction);
const onTouchAction = (
event: React.PointerEvent<HTMLButtonElement>,
id: string,
) => {
if (event.pointerType && event.pointerType !== "touch") return;
if (!touchExpanded) {
event.preventDefault();
setTouchExpanded(true);
setTouchExpandedId(id);
} else {
setTouchExpandedId(id);
}
};
const collapseAfterAction = (
event: React.MouseEvent<HTMLButtonElement>,
) => {
if (event.currentTarget.dataset.multiButtonItemId !== selectedItem?.id) {
const selectedButton = Array.from(
containerRef.current?.querySelectorAll<HTMLButtonElement>(
"button[data-multi-button-item-id]",
) ?? [],
).find(
(button) => button.dataset.multiButtonItemId === selectedItem?.id,
);
selectedButton?.focus({ preventScroll: true });
if (focusRestoreFrameRef.current !== null) {
cancelAnimationFrame(focusRestoreFrameRef.current);
}
focusRestoreFrameRef.current = requestAnimationFrame(() => {
focusRestoreFrameRef.current = null;
const visibleButton = Array.from(
containerRef.current?.querySelectorAll<HTMLButtonElement>(
"button[data-multi-button-item-id]",
) ?? [],
).find((button) => !button.hasAttribute("aria-hidden"));
if (visibleButton && document.activeElement !== visibleButton) {
suppressFocusExpansionRef.current = true;
visibleButton.focus({ preventScroll: true });
}
});
}
setMouseExpanded(false);
setTouchExpanded(false);
setFocusExpanded(false);
setCompactRailReady(false);
setHoveredId(null);
setTouchExpandedId(null);
};
return (
<MultiButtonRail
activeId={activeId}
blobGeometries={blobGeometries}
cellWidth={cfg.cell}
className={className}
compact
containerRef={containerRef}
containerWidth={containerWidth}
expanded={isExpanded}
expandedWidth={expandedWidth}
filterId={filterId}
forwardedRef={ref}
gooey={gooey}
highlightColor={highlightColor}
itemWidths={itemWidths}
interactionReady={compactRailReady}
items={items}
measurementRef={measurementRef}
onAction={collapseAfterAction}
onHover={setHoveredId}
onTouchAction={onTouchAction}
reduceMotion={reduceMotion}
restAriaLabel={restAriaLabel}
restIcon={restIcon}
reserveItems={reserveItems}
rootProps={{
...rootProps,
onMouseEnter: (event) => {
setMouseExpanded(true);
onMouseEnterProp?.(event);
},
onMouseLeave: (event) => {
setMouseExpanded(false);
setHoveredId(null);
onMouseLeaveProp?.(event);
},
onFocusCapture: (event) => {
if (suppressFocusExpansionRef.current) {
suppressFocusExpansionRef.current = false;
} else {
setFocusExpanded(true);
}
onFocusCaptureProp?.(event);
},
onBlurCapture: (event) => {
if (
!event.relatedTarget ||
!event.currentTarget.contains(event.relatedTarget as Node)
) {
setFocusExpanded(false);
setHoveredId(null);
}
onBlurCaptureProp?.(event);
},
onTransitionEnd: (event) => {
handleRailTransitionEnd(event);
onTransitionEndProp?.(event);
},
}}
selectedId={selectedItem?.id}
size={size}
slot="compact-multi-button"
style={style}
variant={variant}
/>
);
},
);
CompactMultiButton.displayName = "CompactMultiButton";
export { CompactMultiButton, MultiButton, MultiButtonGroup };Controls · HTML · CSS · JS
Edit the code and tune it with the controls. The preview updates as you type.

This component runs from a bundled build, so its script is read-only here. Edit the HTML and CSS; the full source is in the Code tab.
Edit every component live, tune it with controls, download the full source and copy the advanced prompts.
$49 one-timePlaceholder price
Test mode: no real payment is taken.
Free: preview, copy buttons and the lesson notes.
A clear shape, one strong colour and a short press response make it feel physical.
Primary actions, calls to action and toolbars.
Change the radius, the padding and the length of the hover transition.
Add the "Multi Button" component from GodUI (github.com/LucasBassetti/godui) (MIT) to my React + Tailwind CSS app. Source file: https://github.com/LucasBassetti/godui/blob/1f632a76a346f09dc9fe066969906c6f98763e1e/packages/lab/src/multi-button. A clear shape, one strong colour and a short press response make it feel physical. Use it for: Primary actions, calls to action and toolbars. Settings to tune: Change the radius, the padding and the length of the hover transition. Support light and dark themes and respect prefers-reduced-motion. Keep the MIT licence notice.
A longer prompt with tuning, accessibility and integration steps.