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

Stylish border radius for Bootstrap progress bars

Here is a snippet of code that I am struggling with: .progress-bar{ border-top-right-radius: 40px !important; border-bottom-right-radius: 40px !important; -webkit-box-shadow: none !important; -moz-box-shadow: none !important; box-sha ...

The hover state of a div will not be lost if its parent element is not being hovered over

When hovering over the second, third, or fourth item, hidden text will appear on the left side. If you hover your cursor over the hidden text, it will disappear again. I want to be able to hover over the second item, move my cursor to "hide", and click o ...

A step-by-step guide on how to use code to verify a Material-UI check-box

Currently, I have integrated Material-UI's Checkbox component into my application along with a corresponding label. I am looking to make both the checkbox and the label clickable. However, I am unable to utilize their FormControlLabel component (feat ...

Steps to trigger a dialog to appear automatically within an Icon Menu with React Material UI

In my application, I have an icon menu implemented along with an array that contains the possible values for the items in the menu. Here is an example of how the array looks: listItems = { [ { label: 'ZERO', t ...

Navigating with buttons in React JS

In my material-ui, I have a button set up like this: <Button style={green} raised="true" label="Continue to create group"}> CREATE NEW GROUP </Button> I am looking to make it so that when the button is clicked, it will take me ...

Issues with zDepth functionality in Material-UI (React.js) not being functional

Can anyone explain the concept of zDepth to me? I have a component with the following render method: render() { return ( <div> <AppBar zDepth={2} title="Some title" iconElementLeft={<IconButton onClick={this ...

Display a group of nested JSON data

In my current project, I am working with a template file that retrieves data from a JSON file and presents it in the form of a list. The initial JSON structure looks like this: "items":[ { "name":"a", } ...

Guide to creating a scrollable container that occupies the remaining height of the screen

Looking to create a fixed container that is scrollable, while keeping the rest of the page fixed? Check out this Stackblitz example. Here's a component called "PageDefault" that includes a Header and wraps each page in the application (the content of ...

Encountering a "Page Not Found" error when trying to refresh a Next.js

Whenever I attempt to reload a routed page in my compact Next.js application, I encounter this error. ...

Issue with vertical alignment in form input text area not functioning properly

Need some help aligning inputted text with the top of a textarea on an HTML form. I've scoured forums for solutions, but no luck so far. I attempted using: textarea{ vertical-align:top;} and input["textarea"]{ vertical-align:top;} Tried adding ...

The swipe motion will be executed two times

By pressing the Circle button, the Box will shift to the right and vanish from view. Further details (FW/tool version, etc.) react scss Typescript framer-motion import "./style.scss"; import React, { FunctionComponent, useState } from &q ...

Highcharts 3D Pie Chart with Drilldown Feature

How can I create a 3D Pie Chart with Drilldown effect? I am having trouble understanding how it works. Here is a JsFiddle Demo for a 3D Pie Chart: JsFiddle Demo And here is a JsFiddle Demo for a 2D Pie Chart with Drilldown feature: JsFiddle Demo You can ...

Solidity smart contract failing to provide accurate output

Within my ERC20 solidity smart contract, I've implemented the following function: function getSummary() public view returns (string, string, address, uint, uint){ return( symbol, name, creator, balances[msg.sender], ...

Sometimes, the page-wide background in Internet Explorer doesn't load properly

Currently, I am working on a website that uses an image as the background for the entire site. Everything seems to be running smoothly in Firefox and Safari, but Internet Explorer is giving me some trouble. Sometimes the image fails to load at all, other t ...

Button for Selecting Colors

I love the color picker button on Google Keep, where a variety of colors pop up for selection. I'd like to add something similar to my website. What steps should I take to implement this feature? ...

Methods for anchoring an element at the bottom of a square container div

* { box-sizing: border-box; } .publication { display: flex; width: 100%; margin-top: 6%; } .bottom1, .bottom2 { display: flex; flex-direction: column; ...

Aligning icons side by side using only CSS styling

I'm having trouble positioning icons next to each other horizontally and they keep stacking on top of one another. Can you please review my CSS code to see if I made a mistake? Here is the CSS: #social { top:20px; left:30px; height:32px; width:200p ...

The Google Pie chart is displaying outside of the designated div area when placed inside a dropdown menu

Encountering an issue with my pie chart rendering outside of its parent div when placed within a dropdown menu. The chart successfully loads after the page is loaded, but only displays correctly if I hover over the dropdown and allow it to load. If I do ...

Label filledInput displayed outside of the input field

I'm currently working with <FilledInput/> using Material UI in conjunction with <InputLabel/>. However, I've encountered an issue where the label is not centered vertically and seems to move "out of bounds" when focused (appearing lik ...

Captivating captions for captivating visuals. Pictures don't conform to a linear arrangement

As someone who is new to website creation, I am currently working on adding a CSS effect where a popup-text appears when an image is hovered over. I want to create a row of images for the popups by using an unordered list. However, I'm facing a proble ...