Ripple
Ripple is a component that adds a ripple effect to elements, allowing users to recognize when they have clicked.
const { onClick, ...rippleProps } = useRipple()
return (
<Center
as="button"
type="button"
onClick={onClick}
h="10"
px="3"
bg="bg.contrast"
color="fg.contrast"
rounded="l2"
position="relative"
overflow="hidden"
>
<Text>Button</Text>
<Ripple {...rippleProps} />
</Center>
)
"use client" to the top of the file.position: relative and overflow: hidden on the parent element of Ripple.Usage
import { Ripple, useRipple } from "@yamada-ui/react"
import { Ripple, useRipple } from "@/components/ui"
import { Ripple, useRipple } from "@workspaces/ui"
<Ripple />
Change the Color
To change the color, set a color to color. By default, currentColor is set.
const { onClick, ...rippleProps } = useRipple()
return (
<Center
as="button"
type="button"
onClick={onClick}
h="10"
px="3"
bg="bg.contrast"
color="fg.contrast"
rounded="l2"
position="relative"
overflow="hidden"
>
<Text>Button</Text>
<Ripple color="warning" {...rippleProps} />
</Center>
)
"use client" to the top of the file.Disable Ripple
To disable, set disabled to true.
const { onClick, ...rippleProps } = useRipple({ disabled: true })
return (
<Center
as="button"
type="button"
onClick={onClick}
h="10"
px="3"
bg="bg.contrast"
color="fg.contrast"
rounded="l2"
position="relative"
overflow="hidden"
>
<Text>Button</Text>
<Ripple {...rippleProps} />
</Center>
)
"use client" to the top of the file.Alternatively, you can disable it by setting disabled to true on Ripple.
const { onClick, ...rippleProps } = useRipple()
return (
<Center
as="button"
type="button"
onClick={onClick}
h="10"
px="3"
bg="bg.contrast"
color="fg.contrast"
rounded="l2"
position="relative"
overflow="hidden"
>
<Text>Button</Text>
<Ripple disabled {...rippleProps} />
</Center>
)
"use client" to the top of the file.Props
Similar Components
Airy
Airy is a component that provides a smooth animation to switch between two elements.
Flip
Flip is a component that provides an animation to switch between two elements while flipping.
Motion
Motion is a convenient component that extends the Yamada UI Style Props to Motion.
Rotate
Rotate is a component that provides an animation to switch between two elements while rotating.
Collapse
Collapse is a component that allows you to expand or collapse an element for display.
Fade
Fade is a component that gradually shows or hides an element.
FadeScale
FadeScale is a component that gradually scales up to reveal or scales down to hide an element.
Skeleton
Skeleton is a component that acts as a placeholder until content is loaded.