【发布时间】:2021-12-23 05:31:42
【问题描述】:
目前,当我单击按钮时,它会显示/关闭侧边栏但没有任何过渡,它应该来自左侧。
它适用于“普通 css”,但我不知道如何使用 Tailwind 创建这种效果。
这是代码:
// this function sets the toggle the value of isOpened so it shows/hides the element
const handleChange = (event: React.MouseEvent) => {
setSidebarState(!isOpened);
onChange && onChange(event, isOpened);
};
// styling so far
<div className='w-12 h-12 bg-red-700 '>
<button onClick={handleChange}>click me</button>
<div className={`h-screen mt-5 fixed z-10 left-0 w-max transition-all ${isOpened ? 'hidden' : ''}`}>
... // content
</div>
</div>
有什么想法吗?
【问题讨论】:
标签: html css reactjs css-transitions tailwind-css