Arrange the columns and rows in a neat layout for the ant design table

I have encountered an alignment issue with the ant design table while listing out my data. The columns are aligned to the right, but the titles for all columns should be aligned to the left by default. You can view the image illustrating this problem using this link: Ant design table alignment issue.

The misalignment of some titles may be caused by small width, which is adjustable. However, the major concern is that all titles are aligned to the right, except for column 1 'Round'.

Below is a snippet of my code:

const tableColumns = [
        {
            title: 'Round',
            dataIndex: 'round',
            width: 80,
        },
        {
            title: 'Date',
            dataIndex: 'date',
            width: 100,
        },
        // Other column definitions go here...
    ];

    const tableData = [
        {
          round: "Round 1",
          date: "10-10-2021",
          price: '0.05 USDC',
          raiseSize: "1000000 SHI",
          // Other data entries go here...
        },
        // Additional data entries go here...
      ];

To display the table, I use the following code:

<Table style={{marginTop:'20px'}} columns={tableColumns} dataSource={tableData} align='center' size="middle" />

Answer №1

It appears that the align property for Column is the solution you are seeking:

let allColumns = [
        {
            title: 'Round',
            dataIndex: 'round',
            width: 80,
        },
        {
            title: 'Date',
            align: 'right', // This is what you need
            dataIndex: 'date',
            width: 100,
        },
...

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

Creating a table row with inline styles using React

Having an issue with a method that returns table rows and trying to set background color for each row. collateRedditResuls() { return this.state.items.map(function (item, index) { return ( <tr style={{'bgcolo ...

React and TypeScript warns about possible undefined object

certificate?: any; <S.Contents>{certificate[0]}</S.Contents> <S.Contents>{certificate[1]}</S.Contents> <S.Contents>{certificate[3]}</S.Contents> If I set the type of props to `any` and use it as an index of an array, e ...

Display a single item from the Bootstrap carousel on mobile devices

Seeking help with my Bootstrap Carousel - displaying 2 items on Desktop but wanting to show one item at a time on Mobile. Any solutions? Visit this link for more info HTML Code: <div class="container"> <div id="myCarousel" class="carousel sli ...

React.js Filter Component

I'm currently trying to create a filter for my "localtypes", but I'm encountering an issue where the console in my browser is displaying an empty array. My goal is to access the localtypes properties of the API that I am working with. I attempte ...

When using TypeScript and React with Babel, an error may occur: "ReferenceError: The variable 'regeneratorRuntime'

I've been delving into learning typescript, react, and babel, and here is the code I've come up with: export default function App(): JSX.Element { console.log('+++++ came inside App +++++++ '); const {state, dispatch} = useCont ...

Tips for simulating next/router in vitest for unit testing?

Struggling with creating basic tests for our Next.js application that utilizes the useRouter() hook, encountering errors when using vitest. In search of solutions to mock next/router for unit testing in conjunction with vitest. ...

Transform the text with a stylish touch within a 'textarea' element

I am currently working on a form with the following design: At the moment, I am at this particular stage and focusing on some minor details: One issue I have encountered is that the "Your text..." appears stuck to the top left corner of the textarea. I a ...

Can you tell me where the slideshow is located in the Gantry position?

Currently, I am working with Gantry framework 4 on Joomla3.2 and have incorporated an Ice slideshow into my website. Despite trying different default positions, the image appears in place but fails to slide as intended. Interestingly, when I switch to the ...

What happens when browsers encounter unfamiliar at-rules?

CSS at-rules have been part of CSS since the days of CSS2. As CSS evolves with new specifications like @supports, it's interesting to see how different browsers handle unsupported rules. Do major browsers simply ignore unrecognized rules, or do they f ...

What is the best method for designing diverse image showcases for mobile devices versus desktops?

I am in the process of building a simple website using React and styling it with Bootstrap. Within my data array, I have stored the images that I wish to showcase on the site. My goal is to iterate through this array and display the images in a 2x2 grid f ...

Unable to edit the current value of an input component in ReactJS

I need to implement a search feature for a list of items using ReactJS. You can view the project on JSBIN. The issue I am facing is that when I input 'mi' in the search box to filter by ID, the filtration works correctly but the input value does ...

Is it possible to develop a route that services both HTML and REST API requests?

Consider this situation: as far as I know, there are three ways to develop a web application The conventional method: Generate the HTML page from the server Uncertain approach: Develop an API and allow the user's browser to retrieve the JavaScript a ...

Display a loading screen while retrieving information in React Redux

I have two sections on the page - a collection of IDs on the left side and data display on the right. When the page loads for the first time, all data related to every ID is shown. However, users can only select one ID at a time to view its specific data. ...

React - Parent Component not successfully passing Ajax data to Child Component

I have a parent component and a child component. I am using the fetch method within the componentDidMount() callback to retrieve data from an API and then set the state with key items to that data. The intention is for this data to be passed down to the ch ...

What is the best method for creating a header design in CSS?

My website code is pretty standard <div class="header"></div> <div class="site-inner"></div> <div class="footer"></div> How can I achieve a header background like the one shown in the image? Do I need to set the entire ...

Full height background image

One issue I'm encountering is that the background image randomly disappears when scrolling down, revealing the background color instead. To better illustrate, here's a gif demonstrating the problem: https://gyazo.com/d2d742a1ff1225babe04faa0a597a ...

The Bootstrap Library reference causes the anchor hover function to malfunction

Feeling frustrated after encountering an issue where the Bootstrap button class interferes with the hover function in standard CSS. Decided to create a custom solution by adding a grey box next to the button to display hover information instead of using t ...

Invalid React element type specified

I'm running into a bit of trouble when trying to publish my node module called material-ui-next-datepicker. Everything seems to be working fine on my local setup, but once installed as a node module, it's causing some issues. import * as React ...

Creating a dynamic matrix layout with CSS

On my e-commerce site's product display page, I am facing some alignment issues. There will be around 100 products on this page and I want to display them in a matrix format. <div style=" margin: 0 auto; width:640px; text-align: left"> &l ...

Encountering issues with React Native's useEffect function while attempting to retrieve the user's authentication status from Firebase

I'm encountering an issue with the useEffect hook. Every time I attempt to retrieve the authentication state of the user following the onAuthStateChanged event, the number of calls within the useEffect becomes excessively high. Occasionally, I also re ...