useAnimatedHeightBetween
Dersom du ikke vil skjule elementet helt, men heller animere mellom to høyder, kan du bruke denne hooken. Her styrer du selv høyden på elementet, og hooken tar seg av animasjonen.
Kom i gang
Se oversikten for hvordan installere pakken.
Live demo
Se et eksempel på stilark på GitHub-repoet vårt.
useAnimatedHeightBetween
Visning
const [isExpanded, setIsExpanded] = React.useState(false);const [animationRef] = useAnimatedHeightBetween(isExpanded, {timing: "expressive",});return (<section ref={animationRef} className="animation-between-example"><p className="jkl-heading-2">Lorem Ipsum</p><p className="jkl-body">Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industrys standard dummy text ever since the1500s, when an unknown printer took a galley of type and scrambled it tomake a type specimen book.</p><p className="jkl-body">It has survived not only five centuries, but also the leap into electronictypesetting, remaining essentially unchanged.</p><p className="jkl-body">It was popularised in the 1960s with the release of Letraset sheetscontaining Lorem Ipsum passages, and more recently with desktop publishingsoftware like Aldus PageMaker including versions of Lorem Ipsum.</p><buttonclassName="jkl-button jkl-button--secondary"data-density="compact"onClick={() => setIsExpanded((prev) => !prev)}>{`Vis ${isExpanded ? "mindre" : "mer"}`}</button></section>);
React API
Her finner du en oversikt over props på komponentene i pakken.