Showcase of all reusable components
Reusable status monitoring widgets with auto-refresh
Interactive toggle switches and mode selectors for switching between states
Used in navbar to switch which account you're TRADING with
Use case: Global trading mode that persists across pages
Behavior: Requires confirmation for live mode, reloads page after switching
Used for switching which account's DATA you're viewing (page-local)
Use case: Page-local view toggle (e.g., Risk Management page)
Behavior: Only changes which data is displayed, doesn't affect trading
Contextual help and information tooltips
Use case: Clarify distinction between view toggles and trading toggles
Pattern: Label + Icon + Tooltip for contextual help
For complex tooltips, use a custom implementation:
You can include any HTML content here, including lists, links, or formatted text.
{% from "components/badge.html" import badge %}
{{ badge("Success", type="success") }}
{{ badge("Error", type="error", size="lg") }}
HTML structure for navbar trading mode toggle:
<!-- Trading Mode Switcher -->
<div class="flex items-center gap-2 mr-4">
<span class="text-sm opacity-70">Mode:</span>
<div class="form-control">
<label class="label cursor-pointer gap-2">
<span class="label-text" id="trading-mode-label">Paper</span>
<input type="checkbox" class="toggle toggle-error"
id="trading-mode-toggle"
onchange="switchTradingMode()">
</label>
</div>
</div>
JavaScript for handling mode switching:
async function switchTradingMode() {
const toggle = document.getElementById('trading-mode-toggle');
const newMode = toggle.checked ? 'live' : 'paper';
// Confirmation for live mode
if (newMode === 'live') {
const confirmed = confirm('⚠️ WARNING: Switching to LIVE TRADING!');
if (!confirmed) {
toggle.checked = false;
return;
}
}
const response = await fetch(`/api/trading-mode?mode=${newMode}`, {
method: 'POST'
});
if (response.ok) {
setTimeout(() => window.location.reload(), 2000);
}
}
Pattern for page-local view toggles with contextual help:
<!-- View Account Data Toggle -->
<div class="mb-6 flex items-center gap-3">
<span class="text-sm font-semibold">View Account Data:</span>
<!-- Button group for switching views -->
<div class="join">
<button class="btn btn-sm join-item trading-mode-btn active"
data-mode="paper">Paper</button>
<button class="btn btn-sm join-item trading-mode-btn"
data-mode="live">Live</button>
</div>
<!-- Info icon with tooltip -->
<div class="tooltip tooltip-right"
data-tip="These buttons switch which account's DATA you're viewing on this page. To change which account you're TRADING with, use the toggle in the top navbar.">
<svg xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5 opacity-70 cursor-help"
fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round"
stroke-width="2"
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</div>
</div>
<!-- Basic tooltip -->
<div class="tooltip" data-tip="This is a tooltip">
<button class="btn">Hover me</button>
</div>
<!-- Tooltip positions -->
<div class="tooltip tooltip-top" data-tip="Top">...</div>
<div class="tooltip tooltip-right" data-tip="Right">...</div>
<div class="tooltip tooltip-bottom" data-tip="Bottom">...</div>
<div class="tooltip tooltip-left" data-tip="Left">...</div>
<!-- Tooltip colors -->
<div class="tooltip tooltip-primary" data-tip="Primary">...</div>
<div class="tooltip tooltip-success" data-tip="Success">...</div>
<div class="tooltip tooltip-error" data-tip="Error">...</div>