update
This commit is contained in:
25
app/component/ScrollTop/ScrollTop.tsx
Normal file
25
app/component/ScrollTop/ScrollTop.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Affix, Button, Transition, rem } from "@mantine/core";
|
||||
import { useWindowScroll } from "@mantine/hooks";
|
||||
import { TbArrowUp } from "react-icons/tb";
|
||||
|
||||
export default function ScrollTop() {
|
||||
const [scroll, scrollTo] = useWindowScroll();
|
||||
|
||||
return (
|
||||
<Affix position={{ bottom: 20, right: 20 }}>
|
||||
<Transition transition="slide-up" mounted={scroll.y > 0}>
|
||||
{(transitionStyles) => (
|
||||
<Button
|
||||
leftSection={
|
||||
<TbArrowUp style={{ width: rem(16), height: rem(16) }} />
|
||||
}
|
||||
style={transitionStyles}
|
||||
onClick={() => scrollTo({ y: 0 })}
|
||||
>
|
||||
Scroll to top
|
||||
</Button>
|
||||
)}
|
||||
</Transition>
|
||||
</Affix>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user