shadcn.io is an independent project built on shadcn/ui
Buttons
ProGlass Button for Svelte UI SDK
A translucent button that blurs what sits behind it, like frosted glass. For Svelte with UI SDK, when a button sits on a photo, a video or a gradient.
On this page7 sections
The Glass Button lets the backdrop show through, softened by a blur. A light edge along the top, a soft shadow under it and a fine border keep its shape clear on any background, and on hover or keyboard focus light gathers along the top of the glass.
Use it over imagery, on a hero, a photo, a video or a bold gradient, where a solid button would look pasted on. On a plain page background there's nothing to blur, so it reads as a quiet outline button; use a regular Button there. It wraps the Button, so size works as usual, and tint takes the place of variant. It's CSS only: a translucent fill, a backdrop-filter, and a sheen that fades in by an opacity transition, with no JavaScript and no animation library. Nothing moves; with reduced motion the sheen appears at once.
Installation
Usage
<script lang="ts">
import { GlassButton } from "@/components/ui/glass-button";
</script>
<GlassButton>Watch the film</GlassButton>
Demos
Blur
blur sets how much of the backdrop survives: subtle (8px) keeps shapes recognizable, medium (12px, the default) turns them into soft color, and strong (24px) leaves only the tone. A busy backdrop behind a small label wants more blur.
Tint
tint="primary" tints the glass with the primary color and switches the label to the primary foreground color, for the one action a hero leads to. The default, neutral, tints it with the page's background color, light in light mode and dark in dark mode.
Accessibility
The button is announced and activated as any Button; the glass is only styling. Keep its label short and check it against the busiest part of the backdrop: the tint is there so text stays readable, and strong blur or tint="primary" helps where the backdrop has strong contrast.
- Enter
- Activate the button.
- Space
- Activate the button.
FAQ
Why does it look like a plain outline button?
Because there's nothing behind it to blur. The effect needs a photo, a video or a gradient underneath; the Blur demo puts it on stripes so you can see it work.
How do I make the blur stronger?
Pass blur="strong" for 24px, or blur="subtle" for 8px. The default, medium, is 12px.
Does it work in dark mode?
Yes. The neutral tint is the page's background color, so the glass is milky in light mode and smoky in dark mode. The light top edge and the shadow swap colors with the mode, so the top edge always looks lit.
Can I use another variant?
No: the glass is always drawn on the ghost Button, so no variant's fill or hover color fights the tint, and there's no variant prop. For a colored glass use tint="primary".
API Reference
GlassButton
data-slot="glass-button-sheen"
blur?"subtle" | "medium" | "strong"
How much the glass blurs what's behind it: subtle is 8px, medium
12px and strong 24px.
- Type
"subtle" | "medium" | "strong"- Default
"medium"
children?Snippet
The label, on the glass.
clickEffect?boolean
Apply a click effect to the button.
- Default
true
debug?boolean
Logs every state change with its reason to the console, in development builds.
disabled?boolean
Stops presses. The button is natively disabled, so it leaves the tab order and its form doesn't submit through it, unless focusableWhenDisabled is set.
- Default
false
focusableWhenDisabled?boolean
Keeps a disabled button in the tab order with aria-disabled instead of the native attribute, so it can hold focus while it becomes disabled and host a tooltip that says why. Presses still do nothing.
- Default
false
isLoading?boolean
Show a loading indicator.
- Default
false
onclick?( event: MouseEvent, details?: ButtonActionDetails ) → unknown
Runs when the button is pressed. Return a Promise to keep it pending
(data-pending) until it settles. details.source says how it was
pressed; a wrapper passing the click on may leave it out.
- Type
( event: MouseEvent, details?: ButtonActionDetails ) → unknown- Parameters
event– React.MouseEvent<HTMLButtonElement>details?– ButtonActionDetails- Returns
unknown
pendingAnnouncement?string
What screen readers hear once the button has been pending for a second, so a slow action doesn't pass in silence. Set it in the page's language. An empty string says nothing.
- Default
"Loading"
tint?"neutral" | "primary"
The glass's tint, in place of a variant: the page's background color,
or the primary color for the main action on a busy backdrop.
- Type
"neutral" | "primary"- Default
"neutral"
type?"button" | "reset" | "submit"
What a native button does in a form: "submit" submits it and "reset" resets it. Ignored when the button renders as something else.
- Type
"button" | "reset" | "submit"- Default
"button"
render?Snippet<[{ props, state, children }]>
Renders your own element: a snippet that gets the part's props to spread on it, its state, and children, its content.
- Type
Snippet<[{ props, state, children }]>
class?string
Merged with the part's classes.
--glass-button-lightstring
The color of the top edge and the sheen (the page's background; its text color in dark mode).
--glass-button-shadowstring
The color of the shadow under the glass (the page's text color; its background in dark mode).





