使用 (Vite + ReactJS + Tailwind CSS v3 + HeroUI)
如果我们在 HeroUI Table 上应用isHeaderSticky
prop,它会添加另一种样式,比如某种阴影、轮廓或边框,我们该如何删除它呢?
生成上述图片的代码是:
<Table
removeWrapper
isHeaderSticky
classNames={{
th: ["!rounded-none", "!shadow-none", "!border-none"],
}}
>
<TableHeader>
<TableColumn key="name">NAME</TableColumn>
<TableColumn key="role">ROLE</TableColumn>
<TableColumn key="status">STATUS</TableColumn>
</TableHeader>
<TableBody items={items} emptyContent={"No permits found"}>
</TableBody>
</Table>
我尝试添加这个:
classNames={{
th: ["!border-none", "!rounded-none", "!shadow-none"],
}}
但它不起作用,所以请问有什么想法吗?
我查看了HeroUI 文档中的示例,
isHeaderSticky
这是一个可行的复制品。这让我看到了 HeroUI 如何设计thead
。因此,中的第一个 tr 子元素
thead
接收该类shadow-small
。第一个tr
本身没有获得,仅在焦点模式下。因此,我只需从元素中outline
删除即可。shadow
thead
让我们看看如何在 中实现类
thead
。<Table>
正如您在问题中提到的那样,该组件具有一个属性,该属性接受带有classNames
键的数组。thead
th
让我们传递它:
传递
shadow-none
给tr
可以工作,但对于th
(正如您在问题中提到的),它绝对不适合,因为阴影应用于thead > tr:first
。最准确的解决方案是告诉
thead
它里面的第一个 tr 不应该接收阴影。或者,应用于
first:shadow-none
可能tr
会有效,但这不仅会从 中去除阴影thead > tr:first
,还会从例如 中去除阴影tbody > tr:first
。