Result Card
ResultCard presents the outcome of an action: saved settings, failed submissions, empty flows, or follow-up next steps.
It is intentionally small, semantic, and HTMX-friendly. Success and info states use role="status"; warning and error states use role="alert".
Import
Basic Usage
ResultCard(
title="Settings saved",
message="Your preferences have been updated.",
status="success",
)
Error State
ResultCard(
title="Could not save",
message="Please review the highlighted fields and try again.",
status="error",
)
With Action
ResultCard(
title="Invite sent",
message="We emailed the new team member.",
status="success",
action=Button("View team", href="/team", variant="primary"),
)
Usage Scenarios
After Form Submission
@app.post("/settings")
def save_settings(...):
if success:
return ResultCard(
title="Settings saved",
message="Your preferences have been updated.",
status="success",
action=Button("Back to dashboard", href="/dashboard"),
)
return ResultCard(
title="Could not save",
message="Please review the highlighted fields and try again.",
status="error",
)
Empty State
ResultCard(
title="No matching records",
message="Try adjusting your search or filter criteria.",
status="info",
action=Button("Clear filters", variant="secondary"),
)
Customizing With Slot Classes
Slot classes let you restyle parts of the card without wrapping it:
ResultCard(
title="Experiment finished",
message="42 runs completed. 3 failed. Full logs attached.",
status="warning",
icon="bi-hourglass-split",
icon_cls="fs-4 text-warning",
title_cls="fw-semibold",
message_cls="text-body-secondary",
)
Parameters
| Param | Type | Description |
|---|---|---|
title |
str |
Main result title. |
message |
str | None |
Optional supporting message. |
status |
success | error | warning | info |
Semantic result state. |
icon |
str | None |
Bootstrap icon name override. |
action |
Any | None |
Optional action component. |
compact |
bool |
Use tighter spacing. |
icon_cls |
str | None |
Extra classes for the icon slot. |
title_cls |
str | None |
Extra classes for the title slot. |
message_cls |
str | None |
Extra classes for the message slot. |
Accessibility
ResultCardusesrole="status"for success/info androle="alert"for warning/error.- Ensure
actionbuttons have accessible names. - Use
compactsparingly when space is constrained and content is minimal.
faststrap.components.display.result_card.ResultCard(title, message=None, *, status='success', icon=None, action=None, compact=False, icon_cls=None, title_cls=None, message_cls=None, **kwargs)
Render a focused result surface for completed actions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Result heading. |
required |
message
|
str | None
|
Optional supporting text. |
None
|
status
|
ResultStatus
|
Semantic outcome driving color and live-region role. |
'success'
|
icon
|
str | None
|
Bootstrap icon name override. |
None
|
action
|
Any | None
|
Optional action element rendered below the text. |
None
|
compact
|
bool
|
Reduce vertical padding for dense layouts. |
False
|
icon_cls
|
str | None
|
Extra classes merged onto the icon (e.g. |
None
|
title_cls
|
str | None
|
Extra classes merged onto the title heading. |
None
|
message_cls
|
str | None
|
Extra classes merged onto the message paragraph. |
None
|
**kwargs
|
Any
|
Additional HTML attributes. |
{}
|