javascript - 如何在 Mantine 中设置标题组件的样式?

标签 javascript css reactjs typescript mantine

我正在尝试在 Mantine 中设置标题组件的样式:https://mantine.dev/core/title/

<Title order={1} my="lg" align="center">
        Upload a new Post
</Title>

根据文档,我们可以使用颜色:<Title order={1} my="lg" align="center" color="blue"并以类似的方式添加渐变。

但是,第一个并没有改变任何东西。而后者会导致错误: 输入 '{ child :字符串;订单:1;我的:“lg”;居中对齐”;梯度:真; }' 不可分配给类型“IntrinsicAttributes & TitleProps & RefAttributes”。 类型“IntrinsicAttributes & TitleProps & RefAttributes”上不存在属性“gradient”。ts(2322)

非常感谢帮助,干杯

最佳答案

如果您需要渐变文本,您可以执行以下操作:

      <Title
        order={1}
        my="lg"
        align="center"
        sx={(theme) => ({
          WebkitBackgroundClip: "text",
          WebkitTextFillColor: "transparent",
          background: theme.fn.linearGradient({ from: "blue", to: "pink", deg: 45 })
        })}
      >
        Upload a new Post...
      </Title>

如果渐变在多个位置重复使用,那么您可以将其拉入您的主题。

enter image description here

关于javascript - 如何在 Mantine 中设置标题组件的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75320501/

相关文章:

reactjs - ReactJS 中无需重复代码的多个下拉菜单

javascript - 使用鼠标围绕中心旋转 Three.js 相机

javascript - AJAX PHP 数据库查询不起作用

JavaScript 隐藏基于子节点列表的 div 不起作用

css - DNN 自定义皮肤未加载正确的 CSS

reactjs - 单击卡组件应创建一条新路线并显示更多信息

javascript - 为什么使用 do-while 而不是简单的 if 语句

javascript - 带有css和jquery的下拉菜单的滑动效果

html - 使用下拉菜单显示滚动条的问题

javascript - 是否可以通过 JavaScript 中的 API 网关将文件对象传递给 AWS Lambda?