Scroll Button
Scroll Button is a React and Tailwind CSS button component from Prompt Kit, licensed MIT. Copy it and paste it into your project.
Prompt Kit
MIT
buttons
What it is
Scroll Button is a React and Tailwind CSS button component from Prompt Kit, licensed MIT. Copy it and paste it into your project.
How to use it
Open it in the catalogue, press copy, and paste it into your project. The prompt you copy carries the code and the rules that tell your agent to reproduce it without changing anything.
Five free copies a month. No card.
Needs
npm i class-variance-authority lucide-react
Licence
This component comes from Prompt Kit and is redistributed under the MIT licence, which permits commercial use. The copyright notice travels with the code.
Scroll Button
"use client"
import { Button, buttonVariants } from "@/components/ui/button"
import { cn } from "@/lib/utils"
import { type VariantProps } from "class-variance-authority"
import { ChevronDown } from "lucide-react"
import { useStickToBottomContext } from "use-stick-to-bottom"
export type ScrollButtonProps = {
className?: string
variant?: VariantProps<typeof buttonVariants>["variant"]
size?: VariantProps<typeof buttonVariants>["size"]
} & React.ButtonHTMLAttributes<HTMLButtonElement>
function ScrollButton({
className,
variant = "outline",
size = "sm",
...props
}: ScrollButtonProps) {
const { isAtBottom, scrollToBottom } = useStickToBottomContext()
return (
<Button
variant={variant}
size={size}
className={cn(
"h-10 w-10 rounded-full transition-all duration-150 ease-out",
!isAtBottom
? "translate-y-0 scale-100 opacity-100"
: "pointer-events-none translate-y-4 scale-95 opacity-0",
className
)}
onClick={() => scrollToBottom()}
{...props}
>
<ChevronDown className="h-5 w-5" />
</Button>
)
}
export { ScrollButton }