Skip to content
Brok UI

Loading…

No results

Stock Widget

Open source

Market cards — a single ticker with an area sparkline, a multi-ticker watchlist, and a price grid.

Preview

resources/views/blocks/stock-widget-watchlist.blade.php Blade
@props([
    'rows' => [
        ['ticker' => 'AAPL', 'company' => 'Apple Inc.', 'price' => '262.24', 'delta' => '4.26', 'trend' => 'down'],
        ['ticker' => 'AMZN', 'company' => 'Amazon.com Inc.', 'price' => '187.24', 'delta' => '7.70', 'trend' => 'up'],
        ['ticker' => 'GOOGL', 'company' => 'Alphabet Inc Class A', 'price' => '290.24', 'delta' => '2.98', 'trend' => 'up'],
    ],
])

<x-ui.card class="w-full max-w-[18rem] flex flex-col p-4">
    <div class="flex items-center justify-between gap-2 pb-2">
        <h3 class="text-sm font-semibold text-foreground">{{ __('Watchlist') }}</h3>
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4 text-muted-foreground" aria-hidden="true"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z" /><circle cx="12" cy="12" r="3" /></svg>
    </div>

    <ul class="flex flex-col">
        @foreach ($rows as $row)
            @php
                $isUp = ($row['trend'] ?? 'up') === 'up';
                $toneClass = $isUp ? 'text-success' : 'text-destructive';
            @endphp
            <li class="flex items-center justify-between gap-2 border-b border-border py-2 last:border-b-0">
                <div class="flex flex-col items-start gap-0.5">
                    <span class="inline-flex items-center gap-2 text-sm font-semibold text-foreground">
                        <svg viewBox="0 0 24 24" fill="currentColor" class="size-2 {{ $toneClass }} {{ $isUp ? '' : 'rotate-180' }}" aria-hidden="true"><path d="M12 4 22 20H2z" /></svg>
                        {{ $row['ticker'] }}
                    </span>
                    <span class="text-xs text-muted-foreground">{{ $row['company'] }}</span>
                </div>
                <div class="flex flex-col items-end gap-0.5">
                    <span class="text-sm font-semibold tabular-nums text-foreground">{{ $row['price'] }}</span>
                    <span class="text-xs font-medium tabular-nums {{ $toneClass }}">{{ ($isUp ? '+' : '-').$row['delta'] }}%</span>
                </div>
            </li>
        @endforeach
    </ul>
</x-ui.card>

Installation

terminal
php artisan ui:add blocks/stock-widget-watchlist

Installs these dependencies automatically:

Registry contract

Install confidence

php artisan ui:add blocks/stock-widget-watchlist writes only the generated targets below. The CLI validates each file hash before writing and prompts before replacing local changes unless --force is used.

Version
1.0.3
License
open
Stability
stable
Contract
v1
Foundation
≥ 1.0.0
Type Generated target
blade resources/views/blocks/stock-widget-watchlist.blade.php

Registry dependencies

card

Package dependencies

composer: jml/brok:^0.2

Use with AI

A brief for your coding agent: what the block is, the install command, how to render it, its props and the rules. Copy it, or open a prompt about this block in an assistant.

stock-widget-watchlist.md
# Brok UI block: Stock Watchlist Widget (`stock-widget-watchlist`)

Watchlist card listing several tickers with a trend triangle, company name, current price, and coloured change percentage per row.

Brok UI is a Laravel Blade registry. `ui:add` copies this block into the app as plain Blade the app owns; it composes installed `<brok:*>` primitives and semantic design tokens.

## Install

```bash
php artisan ui:add blocks/stock-widget-watchlist
```

## Render it

```blade
<x-blocks.stock-widget-watchlist />
```

## Props

- `rows` (array, default `[…]`) — Ticker rows with company, price, change and trend direction.

## Use when

- Listing several stocks in a watchlist card with ticker, price and change per row.
- Tracking multiple instruments in a compact vertical list.

## Avoid when

- Showing one stock in detail with a sparkline; use stock-widget-ticker instead. Wanting a grid layout instead of a list; use stock-widget-grid instead.

## Rules

- Render the installed block with `<x-blocks.stock-widget-watchlist />` and pass data through its props; edit the copied file only for structural changes.
- Keep the semantic design tokens (`bg-background`, `text-muted-foreground`); never swap in raw colour utilities.
- Keep the `data-slot` attributes and the logical (start/end) spacing so the markup still mirrors under `dir="rtl"`.

## Links

- Docs: https://brokui.dev/blocks/stock-widget-watchlist
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/stock-widget-watchlist.json

Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.

Guidance

Use when

  • Listing several stocks in a watchlist card with ticker, price and change per row.
  • Tracking multiple instruments in a compact vertical list.

Avoid when

  • Showing one stock in detail with a sparkline; use stock-widget-ticker instead. Wanting a grid layout instead of a list; use stock-widget-grid instead.

Anti-patterns

  • Do not replace semantic props with conflicting utility classes.
  • Do not remove labels, focus styles, or state attributes.

Usage

Render the block as a component, passing data where useful:

resources/views/welcome.blade.php Blade
<x-blocks.stock-widget-watchlist />

Built from primitives

Composes <brok:*> Semantic tokens Re-themeable RTL-ready

This block composes installed <brok:*> primitives and semantic design tokens only — it does not reimplement any primitive. Re-theme it (light, dark, admin, customer) by editing CSS variables; flip the preview to RTL to confirm it mirrors.

Source

The exact, editable file ui:add writes into your app. The preview above renders this same source — there are no preview-only blocks.

resources/views/blocks/stock-widget-watchlist.blade.php Blade
@props([
    'rows' => [
        ['ticker' => 'AAPL', 'company' => 'Apple Inc.', 'price' => '262.24', 'delta' => '4.26', 'trend' => 'down'],
        ['ticker' => 'AMZN', 'company' => 'Amazon.com Inc.', 'price' => '187.24', 'delta' => '7.70', 'trend' => 'up'],
        ['ticker' => 'GOOGL', 'company' => 'Alphabet Inc Class A', 'price' => '290.24', 'delta' => '2.98', 'trend' => 'up'],
    ],
])

<x-ui.card class="w-full max-w-[18rem] flex flex-col p-4">
    <div class="flex items-center justify-between gap-2 pb-2">
        <h3 class="text-sm font-semibold text-foreground">{{ __('Watchlist') }}</h3>
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4 text-muted-foreground" aria-hidden="true"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z" /><circle cx="12" cy="12" r="3" /></svg>
    </div>

    <ul class="flex flex-col">
        @foreach ($rows as $row)
            @php
                $isUp = ($row['trend'] ?? 'up') === 'up';
                $toneClass = $isUp ? 'text-success' : 'text-destructive';
            @endphp
            <li class="flex items-center justify-between gap-2 border-b border-border py-2 last:border-b-0">
                <div class="flex flex-col items-start gap-0.5">
                    <span class="inline-flex items-center gap-2 text-sm font-semibold text-foreground">
                        <svg viewBox="0 0 24 24" fill="currentColor" class="size-2 {{ $toneClass }} {{ $isUp ? '' : 'rotate-180' }}" aria-hidden="true"><path d="M12 4 22 20H2z" /></svg>
                        {{ $row['ticker'] }}
                    </span>
                    <span class="text-xs text-muted-foreground">{{ $row['company'] }}</span>
                </div>
                <div class="flex flex-col items-end gap-0.5">
                    <span class="text-sm font-semibold tabular-nums text-foreground">{{ $row['price'] }}</span>
                    <span class="text-xs font-medium tabular-nums {{ $toneClass }}">{{ ($isUp ? '+' : '-').$row['delta'] }}%</span>
                </div>
            </li>
        @endforeach
    </ul>
</x-ui.card>

Ownership & lifecycle

Owner, release state, review evidence and adoption for this item.
Owner
Platform UI (@JoshJML)
Current version
1.0.3
Status
Stable
License
open
Deprecation
Not deprecated
Contract
v1
Foundation
≥ 1.0.0