Create Project
Deploy your new project in one-click.
package showcase
import (
"github.com/templui/templui/components/button"
"github.com/templui/templui/components/card"
"github.com/templui/templui/components/input"
"github.com/templui/templui/components/label"
"github.com/templui/templui/components/selectbox"
)
templ CardDefault() {
<div class="w-full max-w-sm">
@card.Card() {
@card.Header() {
@card.Title() {
Create Project
}
@card.Description() {
Deploy your new project in one-click.
}
}
@card.Content() {
<div class="flex flex-col gap-4">
<div class="w-full max-w-sm grid gap-2">
@label.Label(label.Props{
For: "name",
}) {
Name
}
@input.Input(input.Props{
ID: "name",
Placeholder: "Enter project name",
})
</div>
<div class="w-full max-w-sm grid gap-2">
@label.Label(label.Props{
For: "service",
}) {
Service
}
@selectbox.SelectBox() {
@selectbox.Trigger(selectbox.TriggerProps{
ID: "service",
}) {
@selectbox.Value(selectbox.ValueProps{
Placeholder: "Select",
})
}
@selectbox.Content() {
@selectbox.Group() {
@selectbox.Item(selectbox.ItemProps{
Value: "postgres",
}) {
PostgreSQL
}
@selectbox.Item(selectbox.ItemProps{
Value: "mysql",
}) {
MySQL
}
@selectbox.Item(selectbox.ItemProps{
Value: "sqlite",
}) {
SQLite
}
}
}
}
</div>
</div>
}
@card.Footer(card.FooterProps{
Class: "flex justify-between",
}) {
@button.Button(button.Props{
Variant: button.VariantSecondary,
}) {
Cancel
}
@button.Button() {
Deploy
}
}
}
</div>
}
Installation
templui add cardimport "github.com/templui/templui/components/card"Examples
With Image

Featured Card
With top image
This card shows top image usage with lazy loading for better performance.
package showcase
import (
"github.com/templui/templui/components/aspectratio"
"github.com/templui/templui/components/button"
"github.com/templui/templui/components/card"
)
templ CardWithImage() {
<div class="w-full max-w-sm">
@card.Card() {
<div class="overflow-hidden w-full rounded-t-lg">
@aspectratio.AspectRatio(aspectratio.Props{
ID: "top-media-aspect",
Ratio: aspectratio.RatioVideo,
Class: "h-full w-full",
}) {
<img
src="/assets/img/card_placeholder.jpeg"
alt="Card image"
loading="lazy"
class="h-full w-full object-cover"
/>
}
</div>
@card.Header() {
@card.Title() {
Featured Card
}
@card.Description() {
With top image
}
}
@card.Content() {
<p>This card shows top image usage with lazy loading for better performance.</p>
}
@card.Footer() {
@button.Button() {
Learn more
}
}
}
</div>
}
API Reference
Card
Main card container component for organizing related content.
| Name | Type | Default |
|---|---|---|
Unique identifier for the card element. | | - |
Additional CSS classes to apply to the card. | | - |
Additional HTML attributes to apply to the card element. | | - |
Header
Card header section for titles and metadata.
| Name | Type | Default |
|---|---|---|
Unique identifier for the header element. | | - |
Additional CSS classes to apply to the header. | | - |
Additional HTML attributes to apply to the header element. | | - |
Title
Card title component for the main heading.
| Name | Type | Default |
|---|---|---|
Unique identifier for the title element. | | - |
Additional CSS classes to apply to the title. | | - |
Additional HTML attributes to apply to the title element. | | - |
Description
Card description component for additional context.
| Name | Type | Default |
|---|---|---|
Unique identifier for the description element. | | - |
Additional CSS classes to apply to the description. | | - |
Additional HTML attributes to apply to the description element. | | - |
Content
Card content area for the main body.
| Name | Type | Default |
|---|---|---|
Unique identifier for the content element. | | - |
Additional CSS classes to apply to the content. | | - |
Additional HTML attributes to apply to the content element. | | - |