Skip to content

How to generate table in storybook .mdx files #22613

Answered by f3bw
JohnVersus asked this question in Help
Discussion options

You must be logged in to vote

You could try a more complex one (extra styling etc), something like this:

jsx

import React from 'react';

const Table = ({ headers, rows }) => (
  <table>
    <thead>
      <tr>
        {headers.map((header, index) => (
          <th key={index}>{header}</th>
        ))}
      </tr>
    </thead>
    <tbody>
      {rows.map((row, rowIndex) => (
        <tr key={rowIndex}>
          {row.map((cell, cellIndex) => (
            <td key={cellIndex}>{cell}</td>
          ))}
        </tr>
      ))}
    </tbody>
  </table>
);

export default Table;

Markdown:

import Table from './Table';

# My Storybook Documentation

Here's an example table:

<Table
  headers={['Header 1', 'Header 2']}
  rows=…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@JohnVersus
Comment options

@MrXwq
Comment options

Answer selected by JohnVersus
Comment options

You must be logged in to vote
1 reply
@terrymun
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
6 participants