Skip to content

Glass Button for React

A glass button for React is a button that lifts on hover and presses down on tap, with a sweep of light across the filled variants, animated with Motion and kept still under reduced motion.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json

Variants

Files to copy

6 folders · 9 files · 4 packages
From theme/src/
  • components/button/
  • components/spinner/
  • hooks/{use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}
  • motion/{gate.ts, tokens.ts}
  • lib/{cn.ts, form.ts, state-light.tsx}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.jsonRegistry item: button. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Sizes and icons

Loading and disabled

Loading shows a spinner, disables the button and sets aria-busy.

Props

PropTypeDefaultDescription
variant"link" | "danger" | "primary" | "glass" | "outline" | "ghost""primary"Look: "primary" (accent fill), "glass" (frosted), "outline" (edge only), "ghost" (text only), "link" (inline link look) or "danger" (destructive).
size"sm" | "md" | "lg" | "icon""md"Height and padding, the same scale as every form field: "sm" 32px, "md" 40px, "lg" 48px (sm and md are 44px on touch screens), or "icon" for a square as tall as "md".
loadingbooleanfalseShows a spinner, ignores clicks and sets aria-busy. Focus stays on the button.
leadingReactNodeNoneRenders an icon before the children.
trailingReactNodeNoneRenders an icon after the children.
fullWidthbooleanfalseStretch to the full width of the container.
stateLightbooleanfalseLights the button by state: loading glows in the accent colour (data-state="working"), and a data-state of "success", "warning" or "error" flashes its own glow once (an aura, a light pool and a lit edge, drawn on the button's own layer). The state is never conveyed by light alone: keep the label or icon that says it. Off with reduced transparency and forced colours; instant with reduced motion.
nativeButtonbooleantrue; false when render is a non-button elementWhether the rendered element is a native <button>. Defaults to true, or to false when render is something else (e.g. a link): then type/disabled are not added and the disabled state is announced with aria-disabled instead.
renderReactElementNoneRender as another element with the button's look, e.g. a router link: render={<Link to="/" />}.

Keyboard

KeysAction
Tab/Shift + TabMove focus to or from the button (visible focus ring).
Enter/SpaceActivate it. When render is a link, Enter follows the link like any link.

Accessibility

  • A native <button type="button"> by default; with render it becomes a link or your router's Link with the same look.
  • While loading, the button stays focusable (aria-disabled, aria-busy) and ignores clicks, so focus is never lost.
  • An icon-only button (size="icon") needs an aria-label.
  • Touch targets are at least 44 x 44 px; forced colors keep a ButtonText border.

When to use Button

  • Use Button as a glassy, animated button in React for the main call to action on a landing page, with the primary variant for the one action you want taken and glass or ghost for secondary choices beside it.
  • Use the loading prop on a Save or Pay button so the click is ignored while a request runs, the spinner shows, and focus stays on the button.
  • Use the render prop to make a router link look and behave like a button, for example a See pricing link, without nesting an anchor inside a button element.
  • Skip it when the control chooses a value or a view, not an action. Use Toggle for a pressed state, SegmentedControl for one of a few options, and Tabs for switching panels.
  • Pair it with Dialog and Popover triggers through the render prop, Spinner or BorderBeam as children, and Tooltip to name an icon-only button with the icon size.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .