Creating a table with adjustable row heights is a great way to enhance the user

Can the height of an HTML table row be adjusted dynamically by dragging and dropping, similar to how it's done in this demo (https://reactdatagrid.io/docs/row-resize), but for free?

Answer №1

if you prefer a demonstration using HTML, CSS, and vanilla JavaScript (without any libraries), here is an example:

as shown in the GIF, the size adjusts automatically

This example utilizes the contentEditable API available at https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content

let th = document.querySelectorAll("th");
let td = document.querySelectorAll("td");

[th, td].forEach((elAll) => {
  elAll.forEach((el) => {
    el.contentEditable = "true";
  });
});
table {
  border-spacing: 0;
}

th,
td {
  border: 1px solid black;
  padding: 0.5rem;
}
<table>
  <tr>
    <!-- contentEditable attribute will be added here
         <th contenteditable>your content</th>
      -->
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>StackOverFlow</td>
    <td>myName</td>
    <td>Italy</td>
  </tr>
  <tr>
    <td>Facebook</td>
    <td>my second Name</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Google</td>
    <td>my third Name</td>
    <td>France</td>
  </tr>
  <tr>
    <td>Microsoft</td>
    <td>my fourth Name</td>
    <td>America</td>
  </tr>
</table>

The output will resemble something like this:


However, if this appears too challenging,

a simpler solution can involve utilizing an online open source library that offers more ease of use and additional functionalities.

You can conduct some research on Google to find one:

All the technical aspects are handled by another developer, your role is to simply import the library, review the documentation, and begin building

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

How come I am unable to showcase my films using React JS?

I'm encountering issues with my movies app code. The error message I'm seeing is " ./src/App.js: 'MovieList' is not defined react/jsx-no-undef" I need help identifying the problem. Can someone assist me? Thank you! Here is ...

Creating an interactive navigation bar with React.js

I'm working on creating a dynamic navbar that displays different components based on whether the user is logged in or not. If the user is not logged in, the navbar will show three navlinks: About Login Signup If the user is logged in, the navbar wil ...

React: the function is returning as undefined

Description I am encountering an issue with a function in a functional component, as it keeps returning undefined. Despite having all the necessary data defined and accurate within the function including tableData and subtractedStats. This seems to be a ...

Position a div in the center both horizontally and vertically within a section, ensuring that each section expands to fill the entire page when scrolling

I'm currently working on coding a page layout where each section takes up the entire screen. My goal is to have the content within each section centered both vertically and horizontally. I'm unsure if this is achievable, so any guidance or advice ...

Utilize the div element to segment a webpage into four different sections

Within a div tag, I have used 4 other div tags to create equal areas. Is there an alternative method to achieve this division or improve it? <div style="width: 689px; margin-left: 215px; margin-top: 0px; float: none; height: 502px;"> ...

Tips for controlling image sizes on larger devices while maintaining the appearance on Retina displays

I've been searching on the internet, but I got lost in complex explanations. I thought maybe someone here could help me out. :) I have a website with both mobile and desktop versions. Most of it looks good on different devices but there are some elem ...

The alignment of flexbox within a list item is not positioned at the top as expected

When I place a flexbox inside a list item, the content is being pushed down by what seems to be a full line height. I have tried various CSS properties like setting margin-top: 0 for the flexbox, margin-top: 0 for its children, adding flex-wrap to the fle ...

Adjusting body styles in a NextJS application using localStorage prior to hydration: A step-by-step guide

If you visit the React website and toggle the theme, your choice will be saved in localStorage. Upon refreshing the page, the theme remains persistent. In my NextJS project, I am attempting to achieve a similar outcome by applying styles to the body eleme ...

Using Material-UI components as props within Astro by passing React elements

Recently I've been playing around with incorporating MUI React components into my Astro project and so far, everything has been working great. While trying to implement a login form, I encountered an issue with the FormControlLabel element. The docum ...

What is the best way to display data from an Excel spreadsheet on my website?

I'm faced with a challenge in my Excel spreadsheet- I have a mix of numbers and text that I want to turn into graphical representations on a webpage. I'm considering using Python or PHP to achieve this as HTML alone doesn't seem up to the ta ...

Is Amazon altering the names of their CSS selectors and HTML elements on the fly?

For my Amazon.es web scraper built with Selenium, I am using a CSS selector to determine the total number of pages it will iterate through. However, the selector name seems to change dynamically and I must update it daily. As someone not well-versed in H ...

CSS Alignment in React with Material UI

Is there a way to align one button to the left while centering the other two? To see an example in Codesandbox, please visit HERE <DialogActions sx={{ justifyContent: "center" }}> <Button>Left</Button> <Button on ...

How can an input field with a checkbox type be properly placed within a table data tag in a table nested within an AngularJS modal?

Below is the code for my modal: <!-- modal for viewing permissions --> <div id="modal-user-permissions" class="modal"> <div class="modal-content"> <h4 id= ...

Steps for adjusting the position of this div in relation to the main container

Apologies in advance for my lack of HTML skills. I am struggling with a page layout issue. I have a website at . When the window is resized, the ads div on the right side overlaps the main container. What I would like to achieve is to make this ads div re ...

Transform a REACT js Component into an HTML document

I'm working with a static React component that displays information from a database. My goal is to implement a function that enables users to download the React component as an HTML file when they click on a button. In essence, I want to give users ...

Looking for straightforward tips on parsing CSS code

Seeking advice on how to extract rules and property/values from a .css file or <style></style>. I am not in need of an elaborate parser, as the validity of selector text, property name, or value is not important. My main focus is ensuring that ...

Unable to properly load the Kendo Tree View based on the selected option from the combo box in the Kendo UI framework

I am encountering an issue where the Kendo treeview is not populating with different values based on a selection from the Kendo combo box. I have created a JSFiddle to showcase this problem. http://jsfiddle.net/UniqueID123/sample In the scenario provided ...

Tips on serving a static file from a location other than the public or view directories following middleware in Express JS

I am organizing my files in a specific way. Inside the folder api-docs, I have an index.html file along with some CSS and JS files. My goal is to display the API documentation only for authenticated users. Since I am using Jade for views in this proje ...

ReactJS Issue: Failure of Validation on Auto-Populated Form Field

I encountered an issue with the validation setup in my form. The validation checks the input values for "required", "max length", and "min length". Oddly, the validation only works for fields where the user manually types into the input field. I made some ...

Transform a <ul> into an <ol> format (replacing bullets with numbers)

This question presents a challenge, but there may be a solution waiting to be uncovered. Presently, I am utilizing the Kendo UI panelbar for developing expandable lists. However, an issue surfaces when employing an <ol> as the sublist - in this scen ...