Chakra UI Not Displaying Proper Responsiveness on the User Interface

I recently integrated Chakra UI for styling a project on Next.js, and while most components are functioning properly, I am facing challenges with implementing responsive layouts. The styles do not seem to adapt when the screen size is reduced.

Here's my setup:

  • Defined Breakpoints

         const breakpoints = createBreakpoints({ sm: '34em', md: '60em', lg: '76.8em', xl: '144em', });
    
  • theme.ts configuration

     export const chakrauiTheme = extendTheme({
       breakpoints,
       colors: {
         brand: {
           main: '#fff',
         },
       },
     });
    
  • Wrapped _app.tsx with ChakraProvider using theme={chakrauiTheme}

  • There are three approaches in ChakraUI for responsive styling,

1. Utilize Array Syntax

<Box w={[300,400,500,600]}>

2. Use Object Syntax

<Box w={{sm: 300, md: 400, lg: 500, xl:600}}>

3. Another option is to import useBreakpointValue(), although I haven't tried it yet

In theory, these methods should work but unfortunately, I'm not seeing the expected changes in my layout. Current Style Implementation

 export const FormInputWrapper: any = {
  display: 'flex',
  flexDirection: 'column',
  gap: '1rem',
  backgroundColor: ['red', 'green', 'yellow', 'pink'],
  // Color properties added for testing purposes only
  width: ['100%', '60%', '60%', '50%'],
};

Within the component

<Box {...FormInputWrapper}>

I've tried the first two methods without success

I would appreciate any insights on what might be missing from my implementation.

Thank you.

Related Packages:

"@chakra-ui/react": "^1.8.6"
"next": "12.1.0"

Not directly related, but here's how the _app.js file looks like,

<CacheProvider value={emotionCache}>
  <ChakraProvider theme={chakrauiTheme}>
    <ThemeProvider theme={muiTheme}>
      {/* <CssBaseline /> */}
      <Component {...pageProps} />
    </ThemeProvider>
  </ChakraProvider>
</CacheProvider>

Answer №1

It appears that the createBreakpoints() function is no longer being maintained according to this source. Instead, consider utilizing this alternative.

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

The clerk and next.js authentication middleware code falls short in securing my /dashboard route effectively

My dashboard route isn't authenticating properly before entering. I have both my .env and middleware files located outside the app folder. import { authMiddleware } from "@clerk/nextjs"; export default authMiddleware({ // Routes that c ...

Using Next.js to Implement Firebase Push Notifications

Recently, I embarked on a project using Next.js and wanted to integrate Firebase's notification service. Despite following this helpful article, I encountered an issue with the getMessaging() method. The contents of my package.json file: { "na ...

Guidelines for aligning a form in the middle of the screen (positioned between the navigation bar and footer

Before asking this question, I made sure it's not a duplicate by researching previous similar issues with no success. I'm currently utilizing Bootstrap 4. You can view my app at (I'm unable to post the CSS and HTML of my React app due to S ...

Image displayed next to the title on the tanstack table

Currently, I am utilizing the TanStack table within a Next.js application built with React. My objective is to achieve the following functionality: https://i.stack.imgur.com/E8Rii.png However, the tutorial I am following states: const columns = React.us ...

CSS - Achieving full width on hover even when the element has a specified width setting

I am encountering an issue with my CSS. Although I have successfully centered everything, I am facing a problem with the hover effect in CSS. Whenever I apply the active class or hover over an li element, the background color expands to 100%. Additionally, ...

The correct functionality of canvas coordinates may become unreliable once CSS has been implemented

After successfully setting up my drag and drop game in canvas, I decided to make my canvas responsive by adding the following code to my css file: #canvas { width:100% } However, this adjustment caused a discrepancy in my coordinates. Now, when I cli ...

Contrasts in characteristics of CSS images versus SVG graphics

I'm curious if there are distinctions between CSS images and SVGs on your website. When referencing CSS images, I mean images constructed with div elements in HTML and then styled using CSS (such as this: https://codepen.io/andrewrock/pen/jOEZxrY). ...

`how to insert finished HTML & CSS header into WordPress PHP documents`

After dedicating countless hours to studying, I still can't figure out how Wordpress will locate and utilize my alternate header. The code snippet below served as a helpful starting point: <!--?php /* */ if(is_page(23)) { get_header('about&a ...

Solving the NextJS white screen issue occurring on pages with getServerSideProps when directly entering the URL into the browser

Currently using Next 13, I have encountered an issue specifically during the production build phase. Although the site operates normally, when attempting to open a page by directly typing its URL into the browser, it displays either a blank page or a white ...

What's the best way to show floating point numbers in a concise format while also maintaining the ability to perform calculations within this Vue app?

I'm currently developing a compact calculator application using Vue 3 and implementing some custom CSS. For the most part, everything seems to be functioning correctly, except for when the results are long numbers that extend beyond the display limit ...

Place the second division beneath the first within a single navigation bar that adjusts accordingly to all screen sizes

I am experiencing an issue with the layout of my page that has 2 divs within one nav element. When the screen width is greater than 1024px, everything looks fine. However, when I reduce the width to less than 768px, the two divs merge into one line instead ...

I have successfully implemented the Context API in my Next.js project and everything is functioning smoothly. However, I encountered an error while using TypeScript

Currently, I am working on a Next.js project that involves using the Context API. The data fetched from the Context API works perfectly fine, but I am encountering errors with TypeScript and I'm not sure how to resolve them. Error: Property openDialo ...

Is there a way to hide an HTML element from view while still allowing it to be found by the browser?

Scenario: A collection of cards with hidden names, but still necessary to search by name Picture album cards without any album names visible, only the images, yet still searchable using Ctrl+F Is there a particular feature or CSS code that would enabl ...

What is the best way to align the checkbox and label in a React form?

I've been struggling to align the labels next to the checkboxes on this form. I'm currently utilizing React with React-Hook-Form for validation and state management (you can find the code on GitHub: https://github.com/cipdv/ciprmt-mern/blob/main/ ...

Strange HTML antics

On my website, I encountered an issue when trying to register without entering any information into the required fields. The errors were correctly displayed in this screenshot: However, after inserting random characters into each field and attempting to r ...

The SpringMvc tiles are failing to display the header and footer

One of the main components in my project is a file called tiles.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN" "http://tiles.apa ...

JavaScript menu that pops up

Hello everyone, I've recently created an HTML5 file that, when clicked on a specific href link, is supposed to display an image in a smooth and elegant manner. However, so far it hasn't been working for me as expected. Instead of smoothly popping ...

Center a vertically aligned element following a heading, with the content dynamically generated and enclosed in a fixed container

My mind is racing with this problem and I'm not sure if it's solvable, but before throwing in the towel, I thought I'd seek help from the Internet Gods. Here's a visual representation of what I'm aiming for: I want the text to al ...

I am utilizing Docker and NGINX to deploy my NextJS application, allowing me to incorporate a unique base path

After successfully creating an application that works flawlessly locally, I am now faced with the challenge of deploying it on a server with a custom base path. My app is being deployed to a Docker Container where I have another Docker Container running NG ...

Incorporating the use of font color in CSS styles and

I am creating a newsletter template using foundation. Within the table, there are 2 <th> elements containing the content "Reservationnumber" and "23425-FF3234". I have multiple instances of these <th>. I want to apply a colored font to them. Wh ...