Skip to content

how would you deal with a DataTable value that is too long? #1315

Answered by theetrain
halindraprakoso asked this question in Q&A
Discussion options

You must be logged in to vote

@halindraprakoso an alternative you may consider is having your contents wrap. You can achieve this by setting a width key in your respective column heading:

<script>
  import { DataTable } from "carbon-components-svelte";
</script>

<DataTable
  headers={[
    { key: "name", value: "Name" },
    { key: "protocol", value: "Protocol", width: "20ch" }, /* custom width */
    { key: "port", value: "Port" },
    { key: "rule", value: "Rule" },
  ]}
  rows={[
    {
      id: "a",
      name: "Load Balancer 3",
      protocol: "HTTP",
      port: 3000,
      rule: "Round robin",
    }
  ]}
/>

If you want to truncate your copy, then perhaps using slotted cells you could have the text truncate wi…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by halindraprakoso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants