Logo di Prefab Ui

Prefab Ui

Organizzazione
PrefectHQ
prefab-ui

Build interactive UIs with the Prefab component library. Covers PrefabApp, layout (Grid, Row, Card), actions, expressions, and all component imports. Use when building Prefab UI apps, MCP apps with Prefab, FastMCP apps, or generative UIs.

Panoramica

Pubblicato daPrefectHQ
Repositoryprefab
Nome della skillprefab-ui
Stelle
693
Fork
70
File inclusi
3
LicenzaApache-2.0
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • File inclusi: 3

    Script, template e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da PrefectHQ su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Prefab Ui in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/PrefectHQ/prefab/tree/main/skills/prefab-ui
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/PrefectHQ/prefab.git /tmp/prefab
mkdir -p .claude/skills
cp -r /tmp/prefab/skills/prefab-ui .claude/skills/prefab-ui
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Prefab Ui in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Prefab Ui non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Prefab Ui non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Prefab UI

Prefab is a Python DSL for building interactive React UIs. You compose components using context managers, wire up actions as Pydantic models, and wrap everything in a PrefabApp.

This skill covers patterns and layout. For component-specific API details (props, variants, examples), use the component search tool with detail=True.

Core Pattern

python
from prefab_ui.app import PrefabApp
from prefab_ui.components import Column, Heading, Input, Button, Badge
from prefab_ui.components.control_flow import If
from prefab_ui.actions import ShowToast
from prefab_ui.actions.mcp import CallTool

with PrefabApp(state={"query": "", "results": []}) as app:
    with Column(gap=4):
        Heading("User Search")
        Input(name="query", placeholder="Search...")
        Button(
            "Search",
            on_click=CallTool(
                "search_users",
                arguments={"q": "{{ query }}"},
                result_key="results",
                on_error=ShowToast("{{ $error }}", variant="error"),
            ),
        )
        with If("results.length > 0"):
            Badge("{{ results.length }} found", variant="success")
  1. PrefabApp is the outermost context manager — children auto-append
  2. Container components (Column, Card, etc.) use with blocks
  3. state= takes a plain dict of initial client-side state
  4. {{ key }} templates resolve against state at render time
  5. Actions like CallTool call server tools; result_key writes results into state

Always pass state as a plain dict: PrefabApp(state={"count": 0}).

Imports

python
from prefab_ui.app import PrefabApp

# Components — import what you need
from prefab_ui.components import (
    # Layout
    Column, Row, Grid, GridItem, Container,
    Dashboard, DashboardItem, Div, Span,
    # Typography
    Heading, Text, H1, H2, H3, H4, P, Lead, Large, Small, Muted,
    BlockQuote, Label, Link, Markdown, Code,
    # Cards
    Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter,
    # Data display
    DataTable, DataTableColumn, Metric, Badge, Dot,
    Ring, Progress, Separator, Loader, Icon,
    Table, TableHeader, TableBody, TableRow, TableHead, TableCell,
    # Form controls
    Form, Field, Input, Textarea, Button, ButtonGroup,
    Select, SelectOption, Checkbox, Switch, Slider,
    Radio, RadioGroup, DatePicker, Calendar,
    Combobox, ComboboxOption, ChoiceCard,
    # Interactive
    Tabs, Tab, Accordion, AccordionItem,
    Dialog, Popover, Tooltip, HoverCard, Pages, Page,
    # Media
    Image, Audio, Video, Embed, Svg, DropZone,
)
from prefab_ui.components.charts import (
    BarChart, LineChart, AreaChart, PieChart,
    RadarChart, RadialChart, ScatterChart, Sparkline,
    ChartSeries,
)
from prefab_ui.components.control_flow import ForEach, If, Elif, Else

# Actions
from prefab_ui.actions import SetState, ToggleState, ShowToast, OpenLink
from prefab_ui.actions.mcp import CallTool, SendMessage, UpdateContext

Never import from prefab_ui directly except PrefabApp via prefab_ui.app. Spinner does not exist — use Loader. ChartSeries is in prefab_ui.components.charts, not prefab_ui.components.

Layout

Grid vs Row

Use Grid for card layouts and anything that needs equal or proportional columns. Use Row for inline elements (badges, icon + text, buttons):

python
# Equal-width cards — Grid handles sizing automatically
with Grid(columns=3, gap=4):
    with Card(css_class="p-6"):
        Metric(label="Revenue", value="$1.2M")
    with Card(css_class="p-6"):
        Metric(label="Users", value="4,821")
    with Card(css_class="p-6"):
        Metric(label="Uptime", value="99.9%")

# Proportional widths (2:1 ratio)
with Grid(columns=[2, 1], gap=4):
    with Card():
        with CardContent():
            LineChart(...)
    with Card():
        with CardContent():
            Text("Summary")

# Row for inline elements only
with Row(gap=2, align="center"):
    Icon("circle-check")
    Text("Completed")
    Badge("3 items")

Card Patterns

Two patterns — don't mix them in a single Card:

python
# Structured: sub-components have built-in padding
with Card():
    with CardHeader():
        CardTitle("Settings")
        CardDescription("Manage your preferences")
    with CardContent():
        Input(name="name")
    with CardFooter():
        Button("Save")

# Simple: direct children, add padding yourself
with Card(css_class="p-6"):
    Metric(label="Total", value="{{ total }}")

Tabs

Content goes inside each Tab — Tab is a container, not just a header:

python
with Tabs(default_value="overview"):
    with Tab("Overview", value="overview"):
        with Card():
            with CardContent():
                Text("overview content")
    with Tab("Settings", value="settings"):
        Text("settings content")

Metric

python
Metric(label="Revenue", value="$1.2M", delta="+12%", trend="up",
       trend_sentiment="positive", description="vs last month")

delta= is the change text. trend= is "up"/"down"/"neutral" (sets the arrow icon). trend_sentiment= is "positive"/"negative"/"neutral" (sets the color).

DataTable

rows= (not data=), columns use key= and header= (not label=):

python
DataTable(
    columns=[
        DataTableColumn(key="name", header="Name", sortable=True),
        DataTableColumn(key="email", header="Email"),
    ],
    rows=users,  # list of dicts, or "{{ state_key }}"
    search=True,
    search_placeholder="Search contacts...",
    paginated=True,
)

Use search_placeholder= to customize the search input text.

on_row_click= actions fire when the row is clicked and receive the clicked row as $event. Access row fields through $event, for example {{ $event.email }} or EVENT.email.

Layout Props

Column, Row, Grid accept gap, align, justify as native props:

python
Column(gap=4)                        # gap-4
Row(gap=2, justify="between")        # gap-2 justify-between
Grid(columns=3, gap=4)               # grid-cols-3 gap-4

Use css_class for anything beyond these: Column(css_class="max-w-2xl mx-auto").

For app-level styling, use PrefabApp(css=[...]) for inline CSS strings and PrefabApp(stylesheets=[...]) only for external CSS URLs. Stylesheet URLs are loaded as <link> tags and may affect CSP; inline CSS is loaded as <style>.

Carousel

Carousel cycles through children. Each direct child becomes one slide. Three modes through configuration:

python
# Interactive carousel — arrows, dots, swipe
with Carousel(show_dots=True):
    Card(...)
    Card(...)

# Peek — show partial adjacent slides (1.3 = 1 full + 30% of next)
with Carousel(visible=1.3, align="center", dim_inactive=True):
    Card(...)

# Multiple visible slides
with Carousel(visible=3, gap=16):
    Card(...)

# Auto-advancing reel
with Carousel(auto_advance=3000, show_controls=False):
    Card(...)

# Vertical reel
with Carousel(direction="down", visible=3, gap=16, auto_advance=2000, show_controls=False):
    Div(style={"height": "160px"})

# Marquee — continuous smooth scroll
with Carousel(continuous=True, speed=3, show_controls=False):
    Badge("A")
    Badge("B")

# Fade transition
with Carousel(effect="fade", auto_advance=2000, show_controls=False):
    Card(...)

Key props: visible (int/float/None), gap, direction (left/right/up/down), auto_advance (ms), continuous, speed (1-10), effect (slide/fade), dim_inactive, show_controls, controls_position (overlay/outside/gutter), show_dots, align (start/center/end), loop.

Actions

Actions are Pydantic models. All support on_success and on_error:

python
# Client-side (instant)
SetState("count", "{{ count + 1 }}")
ToggleState("showAdvanced")
ShowToast("Done!", variant="success")
OpenLink("https://example.com")

# MCP round-trip
CallTool("search", arguments={"q": "{{ query }}"}, result_key="results")
SendMessage("Summarize {{ item }}")
UpdateContext(content="User selected {{ item }}")

# Chaining — | composes actions into a sequential list
Button(
    "Save",
    on_click=SetState("loading", True)
    | CallTool("save", result_key="saved")
    | SetState("loading", False),
)

# Explicit lists remain supported
Button("Reset", on_click=[SetState("count", 0), ShowToast("Reset")])

on_mount

Every component (and PrefabApp) supports on_mount — actions that fire when the component mounts. Useful for initializing data, starting polling, or running setup logic:

python
# Poll a server tool every 3 seconds when the app loads
PrefabApp(
    view=dashboard_view,
    on_mount=SetInterval(
        duration=3000,
        on_tick=CallTool("refresh", on_success=SetState("stats", RESULT)),
    ),
)

# Load data when a conditional section becomes visible
with Condition("{{ showDetails }}"):
    Column(
        on_mount=CallTool("load_details", on_success=SetState("details", RESULT)),
        children=[Text("{{ details }}")],
    )

Expressions

String props support {{ expression }} templates:

python
Text("Hello, {{ user.name }}!")
Text("{{ items.length }} items ({{ total | currency }})")
Button("{{ loading ? 'Loading...' : 'Submit' }}")

Supports dot paths, arithmetic (+ - * /), comparisons (== != > <), logical (&& || !), ternary (? :), and pipes (| upper, | currency, | length, | truncate:50, etc.).

Special variables: $event (triggering value in onChange/onClick), $error (error message in onError), $index and $item (in ForEach).

Naming Convention

Python uses snake_case; wire protocol uses camelCase. Mapping is automatic: on_click → onClick, css_class → cssClass, etc.

Positional Arguments

Most components accept their primary field positionally:

python
Button("Click me")           # label
Text("Hello")                # content
Heading("Title", level=2)    # content, level
Tab("General")               # title
ForEach("users")             # key
CallTool("search")           # tool
SetState("count", 42)        # key, value
ShowToast("Saved!")          # message

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Prefab Ui?

Build interactive UIs with the Prefab component library. Covers PrefabApp, layout (Grid, Row, Card), actions, expressions, and all component imports. Use when building Prefab UI apps, MCP apps with Prefab, FastMCP apps, or generative UIs.

Perché usare Prefab Ui su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Prefab Ui è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Prefab Ui in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/PrefectHQ/prefab/tree/main/skills/prefab-ui. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Prefab Ui?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Prefab Ui?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Prefab Ui: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Prefab Ui è gratuita?

Sì. È pubblicata su GitHub da PrefectHQ con licenza Apache-2.0. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇