Applying CSS to Components in Next.js: A Step-by-Step Guide

I'm currently working on an app in next.js with chakra UI, and I'm facing a challenge when trying to add a footer. The issue is that I can't seem to get the components under the navbar to fill up the remaining height of the screen.

It appears that my problem might be related to not properly passing CSS styles down to the components.

_app.tsx

import '../styles/globals.css';

function MyApp({ Component, pageProps }) {
  return (
    <ChakraProvider theme={theme}>
    <Navbar></Navbar>
    <Component id='component-container' {...pageProps} />
  )
}

export default MyApp

styles/globals.css

#component-container {
  height: 100%
}

Even if I set the #component-container to have something like color: white, I don't see this CSS being applied to the child components. It seems like I'm missing something in terms of passing the CSS down to the components.

Anyone know how to correctly apply CSS to all components in next.js?

Answer №1

In order to ensure proper functionality, make sure to assign the given ID to an HTML element within the component... At present, you are only passing the ID as a prop to the component without assigning it to any of its internal elements (since I am unaware of your specific component's code). Enter the component and either directly assign the ID to the desired element (likely the initial DIV element) or pass it as a prop to that element.

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

No content in Django's Bootstrap dropdown menu

I need assistance with extracting a list of objects and placing them in a dropdown menu. I have successfully achieved this, but the issue seems to be related to my HTML structure. Here is the code snippet from my HTML: <div class="dropdown"> < ...

Tips on transmitting and receiving substantial JSON information

As a newbie in the full-stack development world, I am currently on a quest to find an efficient method for transmitting and retrieving large data between my React front-end and Express back-end while keeping memory usage to a minimum. My project involves b ...

How to showcase and randomize a data set in a Next.js application

Is there a way to dynamically change the content of a single "Card" component on every page refresh? I want to pull data such as title, subtitle, etc from an array in a data.js file and have it display different content randomly each time. Currently, I am ...

Interested in organizing an array

I need to create a filtered array from my existing arrays which are structured as follows: let arr=[{name:'trt,tet', id:5},{name:td, id:25},{name:fxg, id:1},{name:fs, id:4},{name:ste, id:41}] & let arr1 =[{data:fxg, addr:po 87987},{data:tert ...

Apply a CSS class to the selected radio button when retrieving row data from the table

How can I dynamically add a CSS class to a snippet of code when a radio button is selected? Here's the jQuery Snippet: $(document).ready(function (){ $("input:radio").click(function () { if ($(this).is(":checked")) { var empid ...

SASS malfunctioning, error messages popping up in command prompt while running gulp serve

As I develop a web app using AngularJS and Gulp, I encounter an issue where the CSS does not seem to work when running 'gulp serve'. Despite attempting to reinstall various components like node_modules, Node.js, and Gulp, the same error persists. ...

Is there a way to align this button perfectly with the textboxes?

https://i.sstatic.net/ODkgE.png Is there a way to align the left side of the button with the textboxes in my form? I'm using bootstrap 3 for this. Here is the HTML code for my form. I can provide the CSS if needed. Thanks. h1 { font-size:83px; ...

Fluid layout causing elements in body to be hidden by fixed header

I'm currently tackling a fluid layout challenge, utilizing percentages instead of pixels to achieve it. I've managed to create a fixed heading (#heading) at the top of the page, but now I'm struggling with ensuring that all other elements on ...

Adjust the border color of a TextField in react/material ui based on whether props are required

If a value is required, the TextField border color will be red. Once a value is entered, the red border will disappear. Check out the images by clicking on the links below: Entered Value Without Value with Required field ...

Attempting to create a dynamic dropdown menu with animated effects triggered by a key press

I've been attempting to construct a menu that initially appears as a small icon in the corner. Upon pressing a key (currently set to click), the checkbox is activated, initiating the animation. Most of the menu and animation are functional at this po ...

Struggling to change defaultValue using onChange in a React.js app connected to Firebase

Currently, I am creating a dynamic form that is rendered using map. I have successfully updated all the values into a dictionary and stored them in Firebase. Now, when I submit the form, I need to display the stored values as the default input values. con ...

Modifying the appearance of a Material-UI theme within a deeply embedded component

The structure of my components is as follows: App -> ThemeProvider -> MenuBar -> ThemeControls -> Switch and Autocomplete I aim to enable dark mode using the Switch component and adjust the primary color with the Autocomplete component. To ac ...

Encountering an issue with usememo in React js?

I'm currently experimenting with the useMemo hook in React JS. The goal is to sort an array of strings within a function. However, when I return the array from the function, only the first element is being returned. Can someone please assist me in ide ...

A Webpage that is permanently open, with no option to close it. The only option is to watch the video in

Currently, I am designing web pages for artists to showcase their work in an upcoming exhibition. The pages are ready, but now the artists are requesting that each piece be accompanied by a laptop displaying a single webpage with a video providing informat ...

Nextjs style import function properly on the development server, but faces issues when deployed to production environments

import "../styles.css"; import styles from "react-responsive-carousel/lib/styles/carousel.min.css"; import "react-owl-carousel2/lib/styles.css"; import { Provider } from "react-redux"; import store from "../store/store" function App({ Component, pageProps ...

The Coinbase Pay application fails to compile properly due to a missing Babel loader

Currently, I am working on integrating the coinbase pay sdk into my project. Although I have successfully created a button utilizing their provided examples, I am encountering an issue during the build process which seems to be internal to their SDK. Spec ...

Turn off the background color box with a single click

Whenever I click on a header menu item, the background changes along with it. Is there a way to prevent this from happening? https://i.stack.imgur.com/p6bJ9.png Take a look here ...

React router updates the URL without affecting the actual display

I am facing an issue in my React project where the URL changes when clicking a link, but the view does not update. I have a separate route and links file, and I can't seem to figure out the problem. Here is my index.js: import React from 'react ...

Substitute the division

Can I make the old div change its position and move to the side when I add a new div? And can all the old divs be hidden when adding four new divs? This is for my full news website and I want this applied to all four pages. First page: https://i.sstatic. ...

What is the best way to generate unique mousedown callbacks on the fly?

My goal is to create multiple divs, each with a unique mousedown callback function. However, I want each callback function to behave differently based on the specific div that is clicked. Below is the code I have been using to create the divs and set the ...