标签大小未正确呈现

huangapple go评论64阅读模式
英文:

Tag size is not correctly rendering

问题

我已经创建了一个可重复使用的标题标签,用于在我的Next.js应用程序中实现。在调试时,它显示了正确的标签名称,但在任何标签级别上都没有显示任何差异。

import React from 'react';
import PropTypes from 'prop-types';

const Heading = ({ level, children, className }) => {
    const HeadingTag = `h${level}`;

    return (
        <HeadingTag
            className={`text-xl md:text-2xl lg:text-3xl font-bold ${className}`}
        >
            {children}
        </HeadingTag>
    );
};

Heading.propTypes = {
    level: PropTypes.oneOf([1, 2, 3, 4, 5, 6]).isRequired,
    children: PropTypes.node.isRequired,
    className: PropTypes.string
};

Heading.defaultProps = {
    className: ''
};

export default Heading;

我使用它的方式如下:

<Heading level={6}>我是软件开发者</Heading>
英文:

I have created a reusable heading tag to implement in my Nextjs app. it shows the correct tag name in while dubbing but it does not show any difference on any level of tag.

import React from &#39;react&#39;;
import PropTypes from &#39;prop-types&#39;;

const Heading = ({ level, children, className }) =&gt; {
    const HeadingTag = `h${level}`;

    return (
        &lt;HeadingTag
            className={`text-xl md:text-2xl lg:text-3xl font-bold ${className}`}
        &gt;
            {children}
        &lt;/HeadingTag&gt;
    );
};

Heading.propTypes = {
    level: PropTypes.oneOf([1, 2, 3, 4, 5, 6]).isRequired,
    children: PropTypes.node.isRequired,
    className: PropTypes.string
};

Heading.defaultProps = {
    className: &#39;&#39;
};

export default Heading;

and I am using like this

&lt;Heading level={6}&gt; I&#39;m Software Developer &lt;/Heading&gt;

答案1

得分: 1

标题在Tailwind CSS中没有样式,所以你不会看到任何视觉差异。

你可以为每个级别动态添加不同的类,或者如果你想让它们看起来不同,可以添加基本样式

英文:

Headings are unstyled in Tailwind CSS, so you won't see any visual differences.

You can either dynamically add different classes for each level, or add bases styles if you want them to look different.

huangapple
  • 本文由 发表于 2023年2月18日 17:41:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75492450.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定