Achieving maximum height in Tabs with react-bootstrap

Utilizing React Bootstrap, I have a full screen Modal with Tabs in its body. Within one of these Tabs, I aim to create a Lexical Editor that fills 100% of the width and height of the modal body with some margin.

This is a simplified version of my code:

From the tabs


<Tabs defaultActiveKey="description" className="mt-3">
    <Tab className="text-center m-5 h-100" eventKey="description" title={t("exposition.description")}>
                <TextEditor t={t} />
     </Tab>
</Tabs>

From the text editor

<LexicalComposer initialConfig={initialConfig} className="h-100">
            <RichTextPlugin
                contentEditable={<ContentEditable className="h-100" />}
                placeholder={
                    <div className="h-100">{t("editor.placeholder")}</div>
                }
                ErrorBoundary={LexicalErrorBoundary}
            />
</LexicalComposer>

The source code can be found here.

I attempted setting everything to h-100, but it was ineffective. Subsequently, I experimented with adding CSS3 to .tab-pane and .tab-content, yet determining the correct percentage for the height proved challenging due to device variability, making it non-responsive. I also explored the solution provided in this related question.

Answer №1

The "h-100" class in Bootstrap can be used to adjust the height of an element to 100% of its parent's height. This means that if you set a wrapper's height to, for example, 20rem and apply the "h-100" class to its children, those children will inherit a height of 20rem as well. It is worth mentioning that this class only affects the direct child elements and not their descendants down the hierarchy. Therefore, remember to apply the "h-100" class to each level of children as necessary. In this particular scenario, make sure to also add the "h-100" class to the TextEditor component.

Answer №2

When I initially attempted to style it with this specific CSS class, it failed to function as intended:

.tab-content {
    height: calc(100% - 6rem);
}

It appears that there was an h-100 in the placeholder, resulting in two instances of h-100 being used. This essentially meant I was utilizing 200% of the height, leading to overflow on the page.

I anticipate that this question and answer exchange will prove beneficial to someone out there.

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

Activating a div in React.js using setActive: Step-by-step guide

Currently, I am in the process of developing an application with three menu tabs, each represented by an accordion comprising a menu title and content. The issue I am facing is that when clicking on any menu title, all content divs are displayed simultaneo ...

The interactive Material UI Radio buttons are not responding to click events due to dynamic generation

Click here to see the demo in action: https://codesandbox.io/s/material-demo-9fwlz I expected this code to produce checkable radio elements, but it doesn't seem to be working correctly. Can anyone identify what might be causing the issue? This code s ...

Is there a way to generate a distinctive curved design using CSS for a

I am currently using CSS and div elements in an attempt to create these particular lines: https://i.stack.imgur.com/Ytowq.png .line { width: 1px; height: 100px; background-color: black; position: absolute; border-radius: 50%/100px 1 ...

concealing additional content within a DIV using ellipsis

Looking to conceal additional text within my DIV element with ellipsis (...) at the end Currently using: <div style="width:200px; height:2em; line-height:2em; overflow:hidden;" id="box"> this is text this is text this is text this is text </div ...

Unable to Achieve Full Height with Vuetify Container

Challenge: I'm facing an issue with my <v-container> component not consistently spanning the entire height of the application. Despite trying various methods such as using the fill-height property, setting height: 100%;, height: 100vh;, and expe ...

Issue with Slick Slider when expanding collapsible section in Bootstrap 4

Whenever I expand a bootstrap collapse that contains a carousel, only one carousel item appears instead of all. Is this a bug in Bootstrap or Slick Slider? https://i.sstatic.net/T7Orm.jpg Slider $('.remember__carousel').slick({ slidesToShow: ...

Exploring nested objects within Stylus

My build script compiles my stylus code and includes some data. stylus(stylFile) .set('filename', 'index.css') .define('data', require('./data.json')) .render(...) The data.json file contains groups with nes ...

Align the single element to the right

Is there a way to right align a single element within a dropdown list using Bootstrap 5? I typically use "justify-content-end" for this purpose, but it doesn't seem to work in this case. <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn- ...

The low-level router in React-Router-Dom is designed to solely navigate to a new URL without rendering any components

As a newcomer to the world of Typescript and React, I kindly ask for your patience with me. The issue I am facing involves navigation using buttons rendered as "NavLink" or "Link" from the react-router-dom package. The problem is that only the URL changes ...

Glitches and sudden jumps occur when using the useMediaQuery function in Material UI

Implementing Material UI's useMediaQuery() hook, I have embedded the theme provider and initialized a variable in this way: const theme = useTheme(); const isSmall = useMediaQuery(theme.breakpoints.down('sm') ); I am utilizing the isSmall v ...

React.js encountered an error: Objects cannot be used as a React child (found: object containing keys {type, data})

My current project involves displaying MySQL data in a table using Node.js and React.js. However, I keep encountering the following error: Error: Objects are not valid as a React child (found: object with keys {type, data}). If you meant to render a colle ...

Error: SyntaxError: Encountered an unexpected token '<' in React

I've been grappling with running react without a CDN for days now. Initially, I encountered the error "Uncaught SyntaxError: Cannot use import statement outside a module," which I managed to resolve by using .mjs instead of .js. However, I'm cur ...

What causes flex box to behave differently when transitioning from two columns to three compared to shifting from three columns to four?

I am currently developing an application that presents a variable number of cards to the user in a grid format. The divs defining these cards have both maximum and minimum widths set (375px and 250px, respectively) and are enclosed within a flex container. ...

Leaflet GeoJSON Turf library encountered an error: Invalid coordinates for LatLng object: (undefined, undefined)

After setting the return to null for the component and condition in question to check the data being returned, I thoroughly examined the coordinates arrays without finding any issues. The data comes in as an array of geometry collections containing linest ...

Tips for tracking the evolution of changes to an array within React State

Experiencing challenges with saving the history of updates and modifications on a State. I have an object called "Journey" which includes a list of workshops (another array). Whenever I update my list of workshops, I aim to create a new array that captures ...

Exploring the placement and animation of a Flexbox dropdown menu

I'm currently working on designing a header with three main elements: ---------- LOGO ---------- hidden navigation bar ---------- BUTTON ---------- This header layout is supposed to grow into the following structure: ---------- LOGO ------ ...

A single fetch request triggers multiple GET requests on the server

Here is the code I've written: import React from "react";import { useState, useEffect } from "react";TutorialList from "./TutorialList";PropTypes from "prop-types"; const Home = () => { const [tutorials, s ...

Express server and create-react-app build facing issues with Glyphicons and fonts functionality

Encountering an issue in the browser console: Failed to decode downloaded font "localhost:5000/static/media/fontname.@#$.woff" OTS parsing error: invalid version tag Came across some suggested solutions like adding a homepage:"./" to package.json. However ...

Updating the JSON format output from snake case to camel case in a React web application

Modifying JSON output in a React Web app to change keys from snake case to camel case Currently, the API endpoint response is structured like this: [ { "id": 1, "goals_for": 0, "goals_against": 0, "points": 0 } ] ...

Creating a Stylish ExtJS Container with CSS: A Step-By-Step

I've been experimenting with the ExtJS properties cls, bodyCls, and componentCls but unfortunately, I'm not achieving the desired outcome. As an illustration: Ext.create('Ext.form.Panel', { renderTo: document.body, title: &apo ...