Skip to content

How do I make a clickable link for email? #67

Answered by bryanmylee
rgfx asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @rgfx, you can use the cell property to define custom rendering options for the column body.

https://svelte-headless-table.bryanmylee.com/docs/api/create-columns#columndef-cell-datacell-state-renderconfig

Because Svelte does not have a JSX-equivalent, you cannot inline the definition. Instead, you will have to use a custom solution we developed: createRender.

In your case, you will have a component like:

<!-- TableEmailLinkCell -->
<script lang="ts">
  export let email: string | undefined = undefined;
</script>

{#if email === undefined}
  <span>No email</span>
{:else}
  <a href="mailto:{email}">{email}</a>
{/if}

You would then use it like:

const table = createTable();
const columns = t…

Replies: 2 comments 4 replies

Comment options

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

Answer selected by bryanmylee
Comment options

You must be logged in to vote
3 replies
@blerrgh
Comment options

@bryanmylee
Comment options

@blerrgh
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants