Components / Transitions and utilities
Fade
Fades its children in and out. Shortcut for <Transition effect="fade">.
import { Fade } from "@stylhero/ui";
Example
Code
import { useState, type ReactNode } from "react";
import { Button, Fade, Paper, Stack } from "@stylhero/ui";
function Toggle({ children }: { children: (show: boolean) => ReactNode }) {
const [show, setShow] = useState(true);
return (
<Stack gap={3} align="flex-start">
<Button size="sm" variant="secondary" onClick={() => setShow(!show)}>{show ? "Hide" : "Show"}</Button>
{children(show)}
</Stack>
);
}
const panel = <Paper padding={4} outlined>Animated content</Paper>;
function FadeExample() {
return <Toggle>{(show) => <Fade in={show}>{panel}</Fade>}</Toggle>;
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children required |
ReactNode |
- | |
in required |
boolean |
- | Show or hide the children. |
className |
string |
- | |
direction |
"up" | "down" | "left" | "right" |
- | |
duration |
number |
- | ms. |
keepMounted |
boolean |
- | Keep the children in the DOM while hidden (default: removed after the exit animation). |
Generated from src/components/Transitions.tsx. Something wrong or missing? Open an issue.