Card
Set up
Import Card in the script tag.
<script>
import { Card } from "flowbite-svelte";
</script>
Examples
Simple card with header and content
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla distinctio consequatur modi ab nisi perferendis placeat natus repellendus officiis ipsa.
<Card header="Simple card with header and content">
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400" slot="paragraph">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla distinctio.
</p>
</Card>
Card with a link
Card with link
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla distinctio consequatur modi ab nisi perferendis placeat natus repellendus officiis ipsa.
Read more<Card header="Card with link" link="/" btnLabel="Read more">
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400" slot="paragraph">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla distinctio.
</p>
</Card>
Card with a link and image
Card with link and image
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla distinctio consequatur modi ab nisi perferendis placeat natus repellendus officiis ipsa.
Read more<Card img="/images/image-1.jpeg" header="Card with link and image" link="/" btnLabel="Read more">
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400" slot="paragraph">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla distinctio.
</p>
</Card>
Card with an image
Card with image
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla distinctio consequatur modi ab nisi perferendis placeat natus repellendus officiis ipsa.
<Card img="/images/image-2.jpeg" header="Card with image">
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400" slot="paragraph">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla distinctio.
</p>
</Card>
Card with a Button component
If you need a click handler rather than a link, use a Button component.
Button component
Lorem ipsum dolor sit amet consectetur adipisicing elit.
<script>
const btn1 = () => {
alert('You clicked.')
}
</scipt>
<Card
img="/images/image-1.jpeg"
header="Button component"
btnLabel="Read more"
><span slot="paragraph">
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400" >
Lorem ipsum dolor sit amet consectetur adipisicing elit.
</p>
<div class="w-full pt-4">
<Button name="Click me" on:click={btn1} />
</div>
</span>
</Card>
Card with yellow button
<Card
img="/images/image-1.jpeg"
header="Yellow button"
link="/"
btnColor="yellow"
btnLabel="Read more"
>
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400" slot="paragraph">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla distinctio.
</p>
</Card>
Card with purple button
Purple button
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla distinctio consequatur modi ab nisi perferendis placeat natus repellendus officiis ipsa.
Read more<Card
img="/images/image-1.jpeg"
header="Purple button"
link="/"
btnColor="purple"
btnLabel="Read more"
>
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400" slot="paragraph">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla distinctio
consequatur modi ab nisi perferendis placeat natus repellendus officiis
ipsa.
</p>
</Card>
Props
The component has the following props, type, and default values. See types page for type information.
Name | Type | Default |
---|---|---|
link | string | '' |
rel | string | '' |
alt | string | '' |
img | string | '' |
btnLabel | string | '' |
btnColor | Colors | 'blue' |
textdivClass | string | 'p-5' |
headerClass | string | 'mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white' |
header | string | '' |
divClass | string | 'max-w-sm bg-white rounded-lg border border-gray-200 shadow-md dark:bg-gray-800 dark:border-gray-700' |