Skip to content

Build your personal knowledge base with Trilium Notes

feat(react): add outline Badge variant and a default radius

Elian Doranb52460020268
diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md
index 2186597155..d94b62d960 100644
--- a/.github/copilot-instructions.md
+++ b/.github/copilot-instructions.md
@@ -126,7 +126,7 @@ Common UI components are available in `apps/client/src/widgets/react/` — **alw
- `Slider` - Range slider with label
- `Checkbox`, `RadioButton` - Form controls
- `CollapsibleSection` - Expandable content sections
-- `Badge` - Colored pill/label with optional icon, tooltip, and `onClick` (for counts, status flags); set its color via the `--color` CSS variable on a wrapper class, not inline styles. `BadgeWithDropdown` pairs a badge with a dropdown menu
+- `Badge` - Colored pill/label with optional icon, tooltip, and `onClick` (for counts, status flags). Set its color via the `--color` CSS variable on a wrapper class (not inline styles); pass `outline` for a colored-border/transparent-fill variant instead of a solid background. `BadgeWithDropdown` pairs a badge with a dropdown menu. Don't hand-roll pill/badge markup — reuse this
**Do not use Bootstrap utility classes** (e.g. `form-control-sm`, `form-select-sm`, `input-group`) on these components — they manage their own styling internally. If you need to adjust sizing or layout, use props provided by the component or CSS custom properties, not Bootstrap overrides.
diff --git a/CLAUDE.md b/CLAUDE.md
index 40580abd56..09ab6b83f8 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -131,7 +131,7 @@ Common UI components are available in `apps/client/src/widgets/react/` — **alw
- `Slider` - Range slider with label
- `Checkbox`, `RadioButton` - Form controls
- `CollapsibleSection` - Expandable content sections
-- `Badge` - Colored pill/label with optional icon, tooltip, and `onClick` (for counts, status flags); set its color via the `--color` CSS variable on a wrapper class, not inline styles. `BadgeWithDropdown` pairs a badge with a dropdown menu
+- `Badge` - Colored pill/label with optional icon, tooltip, and `onClick` (for counts, status flags). Set its color via the `--color` CSS variable on a wrapper class (not inline styles); pass `outline` for a colored-border/transparent-fill variant instead of a solid background. `BadgeWithDropdown` pairs a badge with a dropdown menu. Don't hand-roll pill/badge markup — reuse this
Fluent builder pattern: `.child()`, `.class()`, `.css()` chaining with position-based ordering.
diff --git a/apps/client/src/widgets/react/Badge.css b/apps/client/src/widgets/react/Badge.css
index 894351f7d3..5d785153ce 100644
--- a/apps/client/src/widgets/react/Badge.css
+++ b/apps/client/src/widgets/react/Badge.css
@@ -3,7 +3,7 @@
height: 1.9em;
align-items: center;
justify-content: center;
- border-radius: var(--badge-radius);
+ border-radius: var(--badge-radius, 12px);
padding-inline: 8px;
font-size: 0.75em;
letter-spacing: .2pt;
@@ -22,6 +22,18 @@
}
}
+ /* Outline variant: colored border and text over a transparent fill; fills solid on hover. */
+ &.outline {
+ background-color: transparent;
+ color: var(--color);
+ border: 1px solid var(--color);
+
+ &.clickable:hover {
+ background-color: var(--color);
+ color: white;
+ }
+ }
+
.tn-icon {
font-size: 1.2em;
margin-inline-end: 4px;
diff --git a/apps/client/src/widgets/react/Badge.tsx b/apps/client/src/widgets/react/Badge.tsx
index 48fa7fe095..aee39de63f 100644
--- a/apps/client/src/widgets/react/Badge.tsx
+++ b/apps/client/src/widgets/react/Badge.tsx
@@ -19,13 +19,15 @@ interface BadgeProps extends Pick<HTMLAttributes<HTMLDivElement>, "onClick" | "s
className?: string;
tooltip?: string;
href?: string;
+ /** Renders the badge as a colored outline (transparent fill) instead of a solid background. */
+ outline?: boolean;
}
export default function SimpleBadge({ title, className }: SimpleBadgeProps) {
return <span class={`badge ${className ?? ""}`}>{title}</span>;
}
-export function Badge({ icon, className, text, tooltip, href, ...containerProps }: BadgeProps) {
+export function Badge({ icon, className, text, tooltip, href, outline, ...containerProps }: BadgeProps) {
const containerRef = useRef<HTMLDivElement>(null);
useStaticTooltip(containerRef, {
placement: "bottom",
@@ -44,7 +46,7 @@ export function Badge({ icon, className, text, tooltip, href, ...containerProps
return (
<div
ref={containerRef}
- className={clsx("ext-badge", className, { "clickable": !!containerProps.onClick })}
+ className={clsx("ext-badge", className, { "clickable": !!containerProps.onClick, "outline": outline })}
{...containerProps}
>
{href ? <a href={href}>{content}</a> : <span>{content}</span>}
diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.css b/apps/client/src/widgets/type_widgets/options/shortcuts.css
index 939383ce62..db5073b3b1 100644
--- a/apps/client/src/widgets/type_widgets/options/shortcuts.css
+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.css
@@ -25,14 +25,16 @@
color: var(--link-color);
}
- /* Prominent danger pill flagging that conflicts exist; click to filter to them. */
+ /* Prominent danger badge flagging that conflicts exist; click to filter to them. */
.shortcut-conflicts-badge {
flex: 0 0 auto;
--color: var(--icon-button-danger-color, #d9534f);
}
+ /* While the conflicts filter is active, fill the outline badge solid. */
.shortcut-conflicts-badge.active {
- background-color: color-mix(in srgb, var(--color) 75%, black);
+ background-color: var(--color);
+ color: white;
}
}
diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.tsx b/apps/client/src/widgets/type_widgets/options/shortcuts.tsx
index 1b694392c5..d4b94b6f26 100644
--- a/apps/client/src/widgets/type_widgets/options/shortcuts.tsx
+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.tsx
@@ -120,6 +120,7 @@ export default function ShortcutSettings() {
icon="bx bx-error-circle"
text={t("shortcuts.conflicts_badge", { count: conflicts.size })}
tooltip={t("shortcuts.conflicts_badge_tooltip")}
+ outline
onClick={() => setActiveFilter(activeFilter === "conflicts" ? null : "conflicts")}
/>}
<Dropdown