diff --git a/docs/src/assets/styles.css b/docs/src/assets/styles.css
index 26547a1..e3dcaa4 100644
--- a/docs/src/assets/styles.css
+++ b/docs/src/assets/styles.css
@@ -260,6 +260,9 @@
.invisible {
visibility: hidden;
}
+ .visible {
+ visibility: visible;
+ }
.sr-only {
position: absolute;
width: 1px;
@@ -525,6 +528,12 @@
.max-h-\[200px\] {
max-height: 200px;
}
+ .max-h-\[260px\] {
+ max-height: 260px;
+ }
+ .max-h-\[320px\] {
+ max-height: 320px;
+ }
.max-h-\[612px\] {
max-height: 612px;
}
@@ -585,6 +594,9 @@
.w-\[200px\] {
width: 200px;
}
+ .w-\[260px\] {
+ width: 260px;
+ }
.w-\[271px\] {
width: 271px;
}
@@ -612,9 +624,15 @@
.max-w-\[300px\] {
max-width: 300px;
}
+ .max-w-\[320px\] {
+ max-width: 320px;
+ }
.max-w-\[450px\] {
max-width: 450px;
}
+ .max-w-\[720px\] {
+ max-width: 720px;
+ }
.max-w-lg {
max-width: var(--container-lg);
}
@@ -651,6 +669,9 @@
.min-w-\[8rem\] {
min-width: 8rem;
}
+ .min-w-\[260px\] {
+ min-width: 260px;
+ }
.flex-1 {
flex: 1;
}
@@ -1298,6 +1319,10 @@
--tw-shadow: 0 0 #0000;
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
}
+ .shadow-sm {
+ --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
+ }
.shadow-xl {
--tw-shadow: 0 20px 25px -5px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 8px 10px -6px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
@@ -2379,7 +2404,7 @@
&>svg {
color: currentcolor;
}
- h2, h3 {
+ > h2, > h3, > h4, > h5, > h6, > strong, > [data-title] {
grid-column-start: 2;
overflow: hidden;
display: -webkit-box;
@@ -2391,7 +2416,7 @@
--tw-tracking: var(--tracking-tight);
letter-spacing: var(--tracking-tight);
}
- section {
+ > section {
grid-column-start: 2;
display: grid;
justify-items: start;
@@ -2421,7 +2446,7 @@
&>svg {
color: currentcolor;
}
- section {
+ > section {
color: var(--color-destructive);
}
}
diff --git a/docs/src/components/command.njk b/docs/src/components/command.njk
index ec348c0..a932026 100644
--- a/docs/src/components/command.njk
+++ b/docs/src/components/command.njk
@@ -155,9 +155,10 @@ toc:
<div role="menu">
The menu containing the command items. Should have id="{ MENU_ID }" refered to by the input's aria-controls attribute.
- <div role="menuitem">
- - Command item that triggers an action when clicked. In a command-dialog, clicking a menuitem automatically closes the dialog unless the
data-keep-command-open attribute is present. Optional attributes:
+ <div role="menuitem"> or <a role="menuitem">
+ - Command item that triggers an action when clicked. Use
<a> for navigation links, or <div> for actions. In a command-dialog, clicking a menuitem automatically closes the dialog unless the data-keep-command-open attribute is present. Optional attributes:
+ href: If present on an <a>, the item navigates to that URL
data-filter: custom text used for filtering (if different from displayed content, e.g., data-filter="calendar event")
data-keywords: additional keywords for enhanced filtering (e.g., data-keywords="calendar event date")
data-force: forces the item to always display, regardless of filter (e.g., data-force)
@@ -221,6 +222,31 @@ toc:
{% endcall %}{% endraw %}{% endset %}
{{ code_block(raw_code, "jinja") }}
+
+ You can also use the items parameter to pass an array of items:
+
+
+{% set icon_calendar %}{% lucide "calendar" %}{% endset %}
+{% set icon_settings %}{% lucide "settings" %}{% endset %}
+{% set raw_code_items %}{% raw %}{% set icon_calendar %}{% lucide "calendar" %}{% endset %}
+{% set icon_settings %}{% lucide "settings" %}{% endset %}
+{% set items = [
+ { type: "group", label: "Suggestions", items: [
+ { label: "Calendar", icon: icon_calendar, keywords: "date event" },
+ { label: "Search Emoji", icon: icon_settings },
+ { label: "Calculator", disabled: true }
+ ]},
+ { type: "separator" },
+ { type: "group", label: "Settings", items: [
+ { label: "Profile", url: "/profile", icon: icon_settings, keywords: "user account" },
+ { label: "Billing", url: "/billing", icon: icon_settings },
+ { label: "Settings", url: "/settings", icon: icon_settings }
+ ]}
+] %}
+
+{% call command(items=items) %}{% endcall %}{% endraw %}{% endset %}
+{{ code_block(raw_code_items, "jinja") }}
+
diff --git a/src/css/basecoat.css b/src/css/basecoat.css
index 32bb087..20f23dc 100644
--- a/src/css/basecoat.css
+++ b/src/css/basecoat.css
@@ -154,11 +154,16 @@
.alert-destructive {
@apply relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current;
- h2,
- h3 {
+ > h2,
+ > h3,
+ > h4,
+ > h5,
+ > h6,
+ > strong,
+ > [data-title] {
@apply col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight;
}
- section {
+ > section {
@apply text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed;
ul {
@@ -172,7 +177,7 @@
.alert-destructive {
@apply text-destructive bg-card [&>svg]:text-current;
- section {
+ > section {
@apply text-destructive;
}
}
diff --git a/src/jinja/command.html.jinja b/src/jinja/command.html.jinja
index b05feca..009965b 100644
--- a/src/jinja/command.html.jinja
+++ b/src/jinja/command.html.jinja
@@ -143,10 +143,10 @@
Renders a list of items for the command component.
@param items {array} - Array of items to render. Each item can be:
- - { type: "item", label: "Text", content: "HTML", keywords: "search terms", disabled: true, attrs: {} }
+ - { type: "item", label: "Text or HTML", icon: "HTML", url: "href", keywords: "search terms", disabled: true, attrs: {} }
- { type: "group", label: "Group Title", items: [...] }
- { type: "separator" }
- Note: Use attrs to add data-label for alternative search text if needed.
+ Note: Use attrs to add data-label for alternative search text if needed. If url is provided, renders as instead of . Label supports HTML (marked as safe).
@param parent_id_prefix {string} [optional] - The prefix for the item id.
#}
{% macro render_command_items(items, parent_id_prefix="items") %}
@@ -163,25 +163,44 @@
{% endfor %}
{% endif %}
>
- {{ item.label }}
+ {{ item.label | safe }}
{{ render_command_items(item.items, item_id) if item.items }}
{% elif item.type == "separator" %}
{% elif item.type == "item" or not item.type %}
-
- {{ item.content | safe if item.content else item.label }}
-
+ {% if item.url %}
+
+ {% if item.icon %}{{ item.icon | safe }}{% endif %}
+ {{ item.content | safe if item.content else (item.label | safe) }}
+
+ {% else %}
+
+ {% if item.icon %}{{ item.icon | safe }}{% endif %}
+ {{ item.content | safe if item.content else (item.label | safe) }}
+
+ {% endif %}
{% endif %}
{% endfor %}
{% endmacro %}
diff --git a/src/jinja/sidebar.html.jinja b/src/jinja/sidebar.html.jinja
index 16bd1b0..6896aa7 100644
--- a/src/jinja/sidebar.html.jinja
+++ b/src/jinja/sidebar.html.jinja
@@ -117,7 +117,7 @@
>
{% if item.icon %}{{ item.icon | safe }}{% endif %}
- {{ item.label }}
+ {{ item.label | safe }}