The Tailwind Typography plugin simply maintains the default font size of heading tags without altering their style

I've been working on parsing an MDX file and converting it into React components.

My tech stack includes TailwindCSS, Next.js, and React. Following the Tailwind documentation, I have installed the tailwind/typography plugin.

In my tailwind.config.js file:

plugins: [require('@tailwindcss/typography'), require('@tailwindcss/aspect-ratio'), require('tailwindcss-textshadow')]

Within the globals.css file:

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
    h1 {
        @apply mb-6 text-3xl font-semibold;
    }
    h2 {
        @apply text-2xl font-semibold;
    }
    p {
        @apply mb-4;
    }
    a {
        @apply text-blue-500 hover:text-blue-400 dark:text-blue-400 dark:hover:text-blue-300;
    }

Then, in my Blog function, I utilize MDXRemote to render HTML elements.

export const Blog = ({ source, frontMatter }: BlogInput) => {
    return (
            <article className="prose">
                <h2>This should have H2 heading style!</h2>
                <div className={s.title}>{frontMatter.title}</div>
                <div>{format(parseISO(frontMatter.date!), 'MMMM dd, yyyy')}</div>
                <div className="">
                    <MDXRemote {...source} components={components} />
                </div>
            </article>
    )
}

This is an example of my MDX file content:

---
title: Example Post
description: '',
date: '2022-01-30'
image: '/images/hello.jpg'
---

# Heading

### This is an example blog post with React components.

However, when rendered, the custom h1/h2 heading styles are not applied, and instead, it displays as static 16px text (which appears to be the default font style for Tailwind).

Interestingly, when checking the font via the VSCode Preview extension, the font style has visibly changed:

Is there something crucial that I might be overlooking in this setup?

Answer №1

To enhance the design of your website, integrate these CSS lines and customize them to suit your preferences:

h1 {
    @apply text-3xl;
}
h2 {
    @apply text-2xl;
}
h3 {
    @apply text-xl;
}
a {
    @apply text-blue-600 underline;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering difficulties while using JavaScript to complete a form due to issues with loading the DOM

Currently, I am attempting to automate the completion of a multi-page form using JavaScript. Below is the script that I am utilizing: // Page 1 document.getElementById("NextButton").click(); // Page 2 completion(document.getElementById("Rec ...

To initiate a ReactJS project, simply type in "npm start" and encounter a scenario where the computer fails to automatically open a website, causing the

I am trying to create a React.js project using the following command: npx create-react-app my-app cd my-app npm start I have already set the environment variable as C:\Windows\System32\WindowsPowerShell\v1.0. However, when I run the c ...

Typescript Redux Thunk

I've been attempting to create a thunk that filters an array and adds the filtered data to a new array, but I keep encountering an error when trying to dispatch in useEffect. The error message reads: "Argument of type '(dispatch: ThunkDispatch&l ...

When utilizing the dispatch function with UseReducer, an unexpected error is triggered: Anticipated 0 arguments were provided,

Having trouble finding a relevant answer, the only one I came across was related to Redux directly. So here's my question that might be obvious to some of you. In my code, everything appears to be correct but I'm facing an error that says: Expect ...

Tool for controlling the layout of the viewport with Javascript

I have experience using ExtJS in the past to create dashboards, and one of my favorite features is the full-screen viewport with a border layout. This allows for easy splitting of a dashboard into panels on different sides without creating excessive scroll ...

Using the goBack function in React Router does not add the previous location to the stack

In React Router v4, I have a list page and a details page in my web application. I want to implement a 'Save and close' button on the details page that redirects the user back to the list page when clicked. However, I noticed that after the user ...

Issue with website header disappearing

I'm currently struggling with an issue - I can't seem to pinpoint the problem. The header of a website template is functioning perfectly in 1280*800 resolution, but it's breaking on larger monitors (1900*1440). The header consists of three d ...

Using ES6's object destructuring to set default values for nested parameters

Utilizing es6 object destructuring for supplying default parameters to a function. function mapStateToProps({ shops: { cakeShop: {}, pieShop: {} }) { return { CakeShopName: shops.cakeShop.Name, PieShopName: shops.pieShop.Name } } An issue ari ...

How can I trigger a row click event while a TextInput is in focus? (react-native)

Whenever I tap on a ListView item, the TouchableOpacity functions properly. However, when a TextInput is in focus, it requires two taps for it to work - the first tap only removes the focus from the TextInput. Is there a way to make it work without havin ...

The optimal method for selecting a button from a group of buttons on a calculator using pure JavaScript

I have developed an HTML/CSS code inspired by the Mac/Apple calculator design. It features buttons organized in 5 rows using flexbox. You can view my code on this codepen: <div class="wrapper"> <div class="calheader"> ...

Tips for ensuring an animation is triggered only after Angular has fully initialized

Within this demonstration, the use of the dashOffset property initiates the animation for the dash-offset. For instance, upon entering a new percentage in the input field, the animation is activated. The code responsible for updating the dashOffset state ...

Place a div element immediately following a table row in the HTML document

Welcome to my hotel and cabin availability page! I've created a PHP query that displays the available hotels and cabins in a table format. However, I want to enhance the user experience by displaying a Google Maps location and some pictures of each ho ...

CSS - Issue with aligning image captions

I created an HTML snippet that has the following structure: <div class="large-4 columns"> <div class="promo-box"> <a href="#"> <img src="/our-projec ...

Issue with image magnification on Internet Explorer 9 using the Cloud Zoom plugin extension for Joomla

Recently, I've been utilizing a Joomla plugin called cloud zoom to enhance our gallery by providing an image magnification effect when hovering over the large image. You can see it in action on this link here. While it works flawlessly on most browser ...

Is it feasible to relocate an embedded swf file from one tag to another?

My HTML contains two containers for embedded swf files: <div id="player1"></div> <div id="player2"></div> If I load an embedded video into the first div (player1) like this: swfobject.embedSWF("someURL","player1"); Is it possibl ...

Step-by-Step Guide: Customize the Background Color in an Angular 4 Select Dropdown Based on the Selected Option

I'm facing a challenge in setting the background color of a select element based on the color attribute of its currently selected option. I'm using Angular 4 for this task. An example of what I am attempting to accomplish is shown below: <se ...

What is the reason that (click) does not send my data within <button>, while (change) within <input> does in Angular and HTML?

I am facing an issue while trying to send data to my Glassfish RESTful server. The method is activated successfully when I use (change) inside the input tag, but it doesn't work when I try using (click) or (change) to activate the method. I attempted ...

In TypeScript, the 'onChange' is declared multiple times, therefore this particular usage will be scrutinized carefully

Within my React project, I am utilizing material-ui, react-hook-form, and Typescript. However, I encountered an error in VSCode when attempting to add the onChange function to a TextField component: 'onChange' is specified more than once, resul ...

Unable to modify font selection in NextUI for NextJS

I am currently utilizing Nextjs 14 with NextUi for the UI library. The app was set up using: npx create-next-app -e https://github.com/nextui-org/next-app-template However, despite my efforts to modify the fonts in font.ts, the displayed font remains unch ...

Resolve the issue of text overlapping on an image when zooming in

There seems to be an issue with overlapping text and images when zooming the page. I have included a screenshot for reference, please take a look and provide a solution. Thank you in advance. Here is the CSS code causing the overlap: .Pad{ padding: 6 ...