Skip to content

[help] Failed to create custom components #292

Answered by ProQuestionAsker
pahhh-blo asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not sure if this is how this was intended to work, but I did get something working with custom components! 🎉

Here's what I needed:

<!-- p.svelte -->

<p class="text-4xl text-blue-600"><slot /></p>
// components.js 

import p from './p.svelte'

export {p}
// layout.svelte 

<script context="module">
    import { p } from './components/';
    export { p };
</script>

// rest of your layout content goes here

Essentially, create a custom .svelte component that styles the element the way you need it to. Import that into components.js then export it (along with any other custom components). Then import components.js into the context="module" section of your layout file. Hope this helps!

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
7 replies
@pngwn
Comment options

@ProQuestionAsker
Comment options

@pahhh-blo
Comment options

@Ahidada
Comment options

@Ahidada
Comment options

Answer selected by pahhh-blo
Comment options

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

@pngwn
Comment options

@rpf3
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
6 participants
Converted from issue

This discussion was converted from issue #291 on August 19, 2021 18:01.