Mantine - Showing search results in a scrollable list that stops at the parent's height and then adds vertical scrolling

I am currently in the process of developing a web application that needs to occupy the entire height and width of the screen using 100vh and 100vw.

The main app itself should not have any vertical or horizontal scrolling, but individual components/divs within the app are allowed to scroll independently.

In the global CSS settings, I have defined the following:

body {
  background: none !important;
  margin: 0;
  user-select: none;
  height: 100vh !important;
  width: 100vw !important;
  overflow: hidden !important;
}

For my React project, I have incorporated Mantine as my component library.

Users can input search queries which will then display a list of search results.

To showcase the search results, I am utilizing the Stack component.

If the list of search results is long enough to exceed the height of its container, I want the Stack to be able to scroll vertically for users to view all the search results.

  return (
    <div>
      <Grid p={8} gutter="lg">
        <Grid.Col span={4}>
          <TextInput
            placeholder="Search"
            label="Profile Search"
            icon={<IconSearch size={14} />}
            size="lg"
          />
          <Space h="lg" />

          <Stack sx={
            (theme) => (
              {
                overflowY: "auto",
              }
            )}>
            {/* repeated list of search results from query */}
            <SearchResult ... />
        </Stack>
      </Grid.Col>
    </Grid>
  )

I've tried wrapping the Stack in a ScrollArea, but it only works if I set a fixed height.

<ScrollArea style={{ height: 500 }}>
  <Stack sx={ ... }>
    ...
  </Stack>
</ScrollArea>

This approach doesn't provide the desired behavior, as I need the results to adapt responsively to fill the parent's height before overflowing.

Setting the height to 100% causes the Stack to overflow the parent without triggering the scroll function.

<ScrollArea style={{ height: "100%" }}>
  <Stack sx={ ... }>
    ...
  </Stack>
</ScrollArea>

How can I effectively utilize Mantine components to correctly present a list of search results within the parent container's maximum height, allowing for overflow when needed?

Answer №1

Give this a shot to adjust height responsively.

<ScrollBox.Autosize maxHeight={500}>

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

What is the reason for having a space between the <body> and the <html> tags?

Can you explain why there is a gap between the top of the green box and the browser window in Chrome and Firefox? I've tried various CSS configurations to eliminate the apparent space between the html and body elements, but it seems that some padding ...

Creating a Stylish Navigation Bar with Bootstrap4 - Organizing Elements for Just the Right Look

I am trying to organize my content within a navbar into 3 different 'columns'. I want a logo on the left, some navigation items in the center, and the last element ("Get The App") on the right, but I am facing some challenges. Below is my code s ...

Printing Multiple Pages Using JavaScript and Cascading Style Sheets

Encountering difficulties displaying page numbers when printing multiple multipage reports Here is the provided HTML Format : <style type="text/css> body { counter-reset: report 1 page 0; } td.footer:after { counter-increment: page; content ...

Looking for a solution to align the header properly in your React app?

Struggling with aligning a header? The CSS property of the header is inherited from the app's CSS file. For example, in the image below, "Our Mission" is the header that needs to be left-aligned. Looking for some assistance here. You can find the app. ...

Establishing the state of a toggle button after a modification in NextJS/React

One feature I'm currently working on involves a series of toggle buttons that switch between the values 'pending' and 'active'. Whenever a toggle button is clicked, a post request is sent to update the value in the database. Howeve ...

What causes extra React rerenders when removing a component from the return statement?

Initially, my code looked like this: <Container> <Carbs defaultCollapsed/> <Citrus defaultCollapsed/> <Gluten defaultCollapsed/> </Container> Assuming Carbs, Gluten, and Citrus have a similar structure: <Carbs> ...

What is the best way to incorporate Typescript React Components across various projects?

I'm venturing into developing an npm package that involves several react components implemented with typescript. As a newcomer to react and npm, I apologize if my query seems basic. Despite researching online, there isn't much information on this ...

What is the best way to make a selected link stand out with a highlight?

I'm having an issue with the code below that is supposed to keep the selected link highlighted, but it only flashes the green color on click. Can someone help me figure out what's going wrong here? #sidebarContent a:active{ background-colo ...

How can we limit the CSS properties that can be used in an interpolated manner by defining a restricted TS type for CSS props based on emotions?

When dealing with emotions, how can we specify a restricted TS type for the css prop to only allow certain css properties to be interpolated? For instance, consider the following scenario: // This is considered valid css = {{ color: 'white', ...

Issue with event.preventDefault() in Jquery not functioning as expected

My goal is to have the menu display and hide list items on click, with them being hidden by default. However, the issue I am facing is that the menu is generated in the admin section, so it automatically assigns a URL to each item. If I set the URL field o ...

Securing some room beneath the table

I need some extra room below my table. <table border="0" class="medtable"> <tr> <th>User</th> <th>From</th> <th>To</th> </tr> <tr> ... </tr> ...

Having trouble removing just one element from an array in Redux. Any suggestions on how to make it work properly?

I'm currently working on creating a dynamic algorithm for removing an item from an array. Reducer: import { LOAD_PAGES, REMOVE_PAGE } from "./dynamicMenuActions"; export const initialState = { pages: [] }; export const dynamicMenuReducer = (state ...

Resolving timeout problems with Node.js requests

My issue involves a React application that communicates with the node layer using Axios. The node layer, in turn, interacts with an external API that typically takes 7 minutes to respond. Strangely, I receive a timeout error after just 2-3 minutes from the ...

Best practices for using Mock Service Worker to simulate fetch requests in a custom hook

My goal is to conduct testing on my application where users input a query that triggers a request to the Google Books API, followed by displaying the response. To achieve this, I've modularized the data fetching logic into a custom hook. The challenge ...

Passing parameters between various components in a React application

Is it possible to pass a parameter or variable to a different component in React with react-router 3.0.0? For example, if a button is clicked and its onClick function redirects to another component where the variable should be instantly loaded to display a ...

Choose all of the IDs from various sections using Jquery

I am facing an issue with having 2 identical IDs inside 2 separate sections. When the button is clicked, I want it to select the ID within this section and apply a style, then also select the ID in the other section and apply that same style. The code sni ...

Revisiting Dynamic URL Parameters with React Router and Express

After setting up my React router to navigate '/Article/1/' via a link, everything seems to be working fine. However, I encountered an issue when refreshing the browser as it no longer detects my Article component. MainApp.js import React from & ...

Gathering every import within a single file

Is it a good practice to centralize all import files in an allExports.js file and then call them whenever needed from there? My main goal is to have visibility and control over all files from one place... It seems pretty neat and makes the code clear, but ...

Using HTML and CSS to implement a broadened perspective for a specific design

https://i.stack.imgur.com/ckQHa.png Hello, I am facing an issue with a UX design that is optimized for 1200px resolution width. However, when the HTML is loaded in a browser on a larger window resolution, there is a 200px gap on the right side. How can I ...

Differences between Animation Easing in iOS and CSS3 Cubic Bezier Functions

I am currently working on an iOS app and I am trying to improve the animations within it. Having a lot of experience with CSS3 animation and transitions, I want to be able to define my animations in iOS with the same precision that is possible with CSS3 ( ...