shadcn.io is an independent project built on shadcn/ui
Buttons
FreeRipple Button for Svelte UI SDK
Sends a ripple out from the exact point it was pressed, as feedback that the press landed. For Svelte with UI SDK, when a tap should feel answered.
On this page7 sections
Each press starts a circle where the finger or pointer landed, and it spreads to cover the button as it fades. A keyboard press starts it from the center.
Use it where people should feel their press was taken, on a primary action, a toolbar, or a touch screen where there's no hover to lean on. It wraps the Button, so variant and size work as usual. The ripple is a CSS keyframe animation, which the install adds to your stylesheet; a press only writes where it landed into two CSS variables and restarts the animation, so nothing re-renders. It's left out entirely when the system asks for reduced motion.
Installation
Usage
<script lang="ts">
import { RippleButton } from "@/components/ui/ripple-button";
</script>
<RippleButton>Save changes</RippleButton>
Demos
Color
rippleColor is the ripple's color, any CSS color, drawn at about a third of its strength. By default it's the label's color, which reads on every variant. Here an outline button ripples in the primary color and a ghost button in the destructive one, so the feedback matches what the action does.
Duration
duration is how long one ripple takes to spread and fade, in milliseconds, and the default is 600. A short one suits small, frequent actions; a long one gives a large button a slower, softer wave. Ripples from quick repeated presses overlap rather than restart.
Accessibility
The ripple is decoration and hidden from assistive tech: the button is announced and activated as any Button. It starts from the center on Enter and Space, so keyboard presses get the same feedback.
- Enter
- Activate the button.
- Space
- Activate the button.
FAQ
Where does the ripple start?
Where the press landed, measured against the button's own box, so it follows the finger on a wide button, for a mouse, a touch or a pen alike. Enter and Space have no point, so they start it from the center.
How do I change the ripple's color?
Pass rippleColor, any CSS color or a theme variable such as var(--primary). The default is the label's color. The Color demo uses the primary and destructive colors.
How do I make the ripple slower or faster?
Set duration in milliseconds; 600 is the default. The Duration demo shows 350 and 1200.
What happens when someone presses several times quickly?
Each press starts the ripple again from the new point, so a quick double press shows two short ripples rather than a pile of them. There's only ever one ripple element, however often it's pressed.
API Reference
RippleButton
data-slot="ripple-button-ripple"
children?Snippet
The label; the ripple spreads under it.
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
duration?number
How long one ripple takes to spread and fade, in milliseconds.
- Default
600
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"
rippleColor?string
The ripple's color, any CSS color, at a third of its strength. By default the label's color.
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.
--ripple-button-colorstring
The ripple's color (the label's by default).
--ripple-button-durationstring
One ripple's spread and fade (600ms).
--ripple-button-xstring
Where the last press landed, from the left.
--ripple-button-ystring
Where the last press landed, from the top.





