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-ticker.blade.php Blade
@props([
    'ticker' => 'AAPL',
    'company' => 'Apple Inc.',
    'price' => '262.24',
    'delta' => '4.26',
    'trend' => 'down',
    'series' => [36.49, 49.53, 35.16, 41.25, 21.59, 11.98, 21.62, 24.94, 47.34, 27.14, 24.63, 25.45],
])

@php
    $isUp = $trend === 'up';
    $toneClass = $isUp ? 'text-success' : 'text-destructive';
@endphp

<x-ui.card class="w-full max-w-[18rem] flex flex-col gap-2 p-4">
    <div class="flex items-center justify-between gap-2">
        <div class="inline-flex items-center gap-2 {{ $toneClass }}">
            <svg viewBox="0 0 24 24" fill="currentColor" class="size-4 {{ $isUp ? '' : 'rotate-180' }}" aria-hidden="true"><path d="M12 4 22 20H2z" /></svg>
            <span class="text-base font-medium text-foreground">{{ $ticker }}</span>
        </div>
        <span class="text-base font-medium tabular-nums tracking-wide {{ $toneClass }}">{{ ($isUp ? '+' : '-').$delta }}%</span>
    </div>

    <div class="py-2">
        <x-ui.sparkline
            variant="area"
            :data="$series"
            :tone="$isUp ? 'success' : 'destructive'"
            width="280"
            height="60"
            class="w-full"
        />
    </div>

    <div class="flex items-end justify-between gap-2">
        <span class="text-sm text-muted-foreground">{{ $company }}</span>
        <span class="text-3xl font-medium tabular-nums text-foreground">{{ $price }}</span>
    </div>
</x-ui.card>

Installation

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

Installs these dependencies automatically:

Registry contract

Install confidence

php artisan ui:add blocks/stock-widget-ticker 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-ticker.blade.php

Registry dependencies

card sparkline

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-ticker.md
# Brok UI block: Stock Ticker Widget (`stock-widget-ticker`)

Single stock ticker card with a trend triangle, change percentage, area sparkline, and the current price.

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-ticker
```

## Render it

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

## Props

- `ticker` (string, default `AAPL`) — Stock ticker symbol.
- `company` (string, default `Apple Inc.`) — Company name shown under the ticker.
- `price` (string, default `262.24`) — Current price value.
- `delta` (string, default `4.26`) — Change percentage magnitude.
- `trend` (string, default `down`) — Direction of the change ("up" or "down"), which also tints the sparkline.
- `series` (array, default `[36.49, 49.53, 35.16, 41.25, 21.59, 11.98, 21.62, 24.94, 47.34, 27.14, 24.63, 25.45]`) — Sparkline data points.

## Use when

- Showing a single stock's ticker, price, change percentage and an area sparkline.
- Needing a compact single-instrument widget rather than a watchlist or grid.

## Avoid when

- Showing several tickers at once; use stock-widget-watchlist or stock-widget-grid instead.

## Rules

- Render the installed block with `<x-blocks.stock-widget-ticker />` 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-ticker
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/stock-widget-ticker.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

  • Showing a single stock's ticker, price, change percentage and an area sparkline.
  • Needing a compact single-instrument widget rather than a watchlist or grid.

Avoid when

  • Showing several tickers at once; use stock-widget-watchlist or 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-ticker />

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-ticker.blade.php Blade
@props([
    'ticker' => 'AAPL',
    'company' => 'Apple Inc.',
    'price' => '262.24',
    'delta' => '4.26',
    'trend' => 'down',
    'series' => [36.49, 49.53, 35.16, 41.25, 21.59, 11.98, 21.62, 24.94, 47.34, 27.14, 24.63, 25.45],
])

@php
    $isUp = $trend === 'up';
    $toneClass = $isUp ? 'text-success' : 'text-destructive';
@endphp

<x-ui.card class="w-full max-w-[18rem] flex flex-col gap-2 p-4">
    <div class="flex items-center justify-between gap-2">
        <div class="inline-flex items-center gap-2 {{ $toneClass }}">
            <svg viewBox="0 0 24 24" fill="currentColor" class="size-4 {{ $isUp ? '' : 'rotate-180' }}" aria-hidden="true"><path d="M12 4 22 20H2z" /></svg>
            <span class="text-base font-medium text-foreground">{{ $ticker }}</span>
        </div>
        <span class="text-base font-medium tabular-nums tracking-wide {{ $toneClass }}">{{ ($isUp ? '+' : '-').$delta }}%</span>
    </div>

    <div class="py-2">
        <x-ui.sparkline
            variant="area"
            :data="$series"
            :tone="$isUp ? 'success' : 'destructive'"
            width="280"
            height="60"
            class="w-full"
        />
    </div>

    <div class="flex items-end justify-between gap-2">
        <span class="text-sm text-muted-foreground">{{ $company }}</span>
        <span class="text-3xl font-medium tabular-nums text-foreground">{{ $price }}</span>
    </div>
</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