Components / Transitions and utilities
Grow
Scales and fades its children in from their origin. Shortcut for <Transition effect="grow">.
import { Grow } from "@stylhero/ui";
Example
Code
import { useState, type ReactNode } from "react";
import { Button, Grow, 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 GrowExample() {
return <Toggle>{(show) => <Grow in={show}>{panel}</Grow>}</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.