Skip to content

DataTable align column numeric #1618

Answered by farens
eduardocapria asked this question in Q&A
Discussion options

You must be logged in to vote

To align the cell values of a column to the right, you can use the slot "cell" like:

<svelte:fragment slot="cell" let:cell>
    {#if cell.key === 'amount'}
        <div style="text-align:right">{formatCurrency(cell.value)}</div>
    {:else}
        {cell.value}
    {/if}
</svelte:fragment>

To align the header's label i tried the same with the slot "header", but this didn't work, because the label is nested in a button element and a div. The button is a flexbox. Using some global css to push the div in the button to flex-end will work, but i didn't figure out how to do this yet, as i am still new to svelte.

Aligning the header's label on the right can be done with css like:

:global(#my-dat…

Replies: 1 comment

Comment options

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

This discussion was converted from issue #771 on January 09, 2023 17:02.