KartaWeb. CoreComponents
(Karta v1.0.0)
The components of the admin interface: Karta's own, on Tailwind
utilities and the colour tokens of assets/css/app.css. The design
system guide (guides/contributing/admin-design-system.md) says which
to use where; a page is built from these and adds layout utilities only.
Every component renders under the admin pages' content security policy:
no inline style, no inline script, no event handler attribute. The one
piece of browser code here, copying to the clipboard, is a colocated
hook that is bundled into app.js.
Summary
Functions
A small label with a tone: neutral, ok, warn, bad, info,
violet or brand. For the states of records use state/1, which
picks the tone, the icon and the words.
A bar chart drawn on the server as SVG (no script, no style attribute):
one bar per {label, value}, scaled to the largest value; each bar's
label and value are its tooltip. label describes the whole chart for
screen readers.
A button, or a link that looks like one when it has href, navigate
or patch. variant: secondary (the default), primary (the one main
action of a form or page), ghost (actions in tables and toolbars),
danger (removes or stops something, with data-confirm) and
danger-ghost. size: md or sm. class adds classes.
A notice inside the page, for a state the reader must know about (a
suspended server, a value shown once). tone is one of the status tones.
The highlight of a row that changed in a live page's last update:
k-changed-a and k-changed-b alternate from one update to the next
(refreshes, see KartaWeb.LiveUpdates), so that a row that changes
again lights up again. None with reduced motion (the stylesheet).
A button that copies text to the clipboard: the text of the element
target names (a CSS selector), so a secret is in the page only once.
It says "Copied" for a moment afterwards. Browsers allow the clipboard
only on HTTPS pages and on localhost.
A value to copy: an identifier, a token, a DNS record. Shown in the monospace font, broken anywhere, with a copy button.
A DNS record to publish: its type, name and value, each to copy. A value of several strings (a long TXT record) is given as a list and shown one string a line.
What a list says when it is empty: what is missing, and what to do about
it (inner_block, actions).
The file field of a LiveView upload (allow_upload/3), laid out as
<.input> lays out the other fields: the label above, the help below,
then what is wrong with the file. errors gives the words for an upload
error (:too_large, :not_accepted, :too_many_files).
A flash notice, at the top right; a click dismisses it.
A time as timestamp/1 writes it: 2026-11-08 14:03 UTC.
The heading of a page: its title, a line under it, and the page's own actions on the right.
A Heroicon: hero-<name> (outline, 24 px),
-solid, -mini (20 px) or -micro (16 px). Size and colour come from
class. Decorative: give the element around it a label when the icon
alone carries meaning.
An input with its label, help and errors. A Phoenix.HTML.FormField
gives the name, id, value and errors.
A list of facts: a term and its value per row.
The sign that a page updates by itself (KartaWeb.LiveUpdates): "Live",
in a panel's header. It shows only while the page is connected (the
phx-connected class LiveView puts on the page), so it goes when the
connection is lost.
Links to the pages next to a page of Karta.Pager: to makes the path
of a page from its cursor (%{"before" => id} or %{"after" => id}),
with ~p and the page's own route. Nothing when there is only one page.
A section of a page: a titled surface. flush drops the inner padding,
for a table that fills it.
A secret shown once (a new API key, a new password, a webhook's signing
secret): the value with a copy button, why it will not be shown again,
and the action that drops it (actions). kept says how Karta keeps
it: "hash" (the default: it can check the secret but not show it) or
"encrypted" (it needs the secret itself, to sign with). Render it only
while the page holds the secret.
A number to take in at a glance, with what it counts. tone colours the
icon only; the number stays in the text colour.
The state of a record as a badge: a recipient or a delivery attempt
(:queued, :deferred, :delivered, :bounced, :suppressed), a
received message's delivery (:pending, :delivered, :failed,
:accepted when it was only stored, :held when it is held), a
server (:active, :suspended), a credential (:active, :revoked), a
domain (:verified, :unverified), a DKIM key (:pending, :active,
:retiring, :retired), a tracking host (:pending before its first
check, :verified, :unverified), a tracking event (:open,
:click), a DNS check and its findings (:pass, :warn, :fail,
:missing; :pending before its first result), a webhook (:on,
:off, :failing while its requests fail, :stopped when Karta switched
it off because they kept failing), a report run (:pending, :done,
:skipped, :failed), a received report (:parsed, the
report was read, :failed), a webhook delivery (:pending,
:retrying after a failed request, :succeeded, :failed). An IP
pool's address is :held_here on the node serving the page and
:not_here on another. With count, the words are "3 delivered".
The words for a state, as state/1 shows them (for selects and text).
A table: dense rows, a sticky header, horizontal scrolling on narrow
screens. rows may be a list or a stream (@streams.name); id is the
tbody's. A column's class aligns it (text-right for numbers) or
sets its font (font-mono for identifiers).
A time, in UTC, in a <time> element. precision is :minute (the
default), :second or :day. Nothing for nil.
Translates an error message using gettext.
Translates the errors for a field from a keyword list of errors.
Functions
A small label with a tone: neutral, ok, warn, bad, info,
violet or brand. For the states of records use state/1, which
picks the tone, the icon and the words.
Attributes
id(:string) - Defaults tonil.tone(:string) - Defaults to"neutral". Must be one of"neutral","ok","warn","bad","info","violet", or"brand".icon(:string) - Defaults tonil.class(:any) - Defaults tonil.
Slots
inner_block(required)
A bar chart drawn on the server as SVG (no script, no style attribute):
one bar per {label, value}, scaled to the largest value; each bar's
label and value are its tooltip. label describes the whole chart for
screen readers.
<.bar_chart id="per-hour" label="Messages per hour" bars={[{"09:00", 4}, {"10:00", 9}]} />Attributes
id(:string) (required)label(:string) (required)bars(:list) (required) -{label, value}pairs, in order.
A button, or a link that looks like one when it has href, navigate
or patch. variant: secondary (the default), primary (the one main
action of a form or page), ghost (actions in tables and toolbars),
danger (removes or stops something, with data-confirm) and
danger-ghost. size: md or sm. class adds classes.
<.button variant="primary">Save</.button>
<.button navigate={~p"/"}>Organisations</.button>
<.button variant="danger-ghost" size="sm" data-confirm="Revoke it?">Revoke</.button>Attributes
variant(:string) - Defaults to"secondary". Must be one of"primary","secondary","ghost","danger", or"danger-ghost".size(:string) - Defaults to"md". Must be one of"sm", or"md".class(:any) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["href", "navigate", "patch", "method", "download", "name", "value", "disabled", "form", "type", "rel"].
Slots
inner_block(required)
A notice inside the page, for a state the reader must know about (a
suspended server, a value shown once). tone is one of the status tones.
<.callout id="suspended" tone="warn" icon="hero-pause-circle" title="Suspended">
Its credentials are refused.
</.callout>Attributes
id(:string) - Defaults tonil.tone(:string) - Defaults to"info". Must be one of"info","ok","warn","bad", or"neutral".icon(:string) - Defaults tonil.title(:string) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_blockactions
@spec changed_class(non_neg_integer()) :: String.t()
The highlight of a row that changed in a live page's last update:
k-changed-a and k-changed-b alternate from one update to the next
(refreshes, see KartaWeb.LiveUpdates), so that a row that changes
again lights up again. None with reduced motion (the stylesheet).
A button that copies text to the clipboard: the text of the element
target names (a CSS selector), so a secret is in the page only once.
It says "Copied" for a moment afterwards. Browsers allow the clipboard
only on HTTPS pages and on localhost.
<code id="token">{@token}</code>
<.copy_button id="copy-token" target="#token" label="Copy the token" />Attributes
id(:string) (required)target(:string) (required) - a CSS selector for the element whose text is copied.label(:string) - what a screen reader announces. Defaults to"Copy".
A value to copy: an identifier, a token, a DNS record. Shown in the monospace font, broken anywhere, with a copy button.
<.copyable id="server-token" label="Copy the token">{@server.token}</.copyable>Attributes
id(:string) (required)label(:string) - Defaults to"Copy".class(:any) - Defaults tonil.
Slots
inner_block(required)
A DNS record to publish: its type, name and value, each to copy. A value of several strings (a long TXT record) is given as a list and shown one string a line.
<.dns_record id="dkim-1" type="TXT" name="karta-ab._domainkey.example.com" value={@txt} />Attributes
id(:string) (required)type(:string) (required)name(:string) (required)value(:any) (required) - the value, or a list of character-strings.
What a list says when it is empty: what is missing, and what to do about
it (inner_block, actions).
<.empty_state id="no-servers" icon="hero-server-stack" title="No mail servers yet">
A mail server sends and keeps an application's mail.
</.empty_state>Attributes
id(:string) (required)icon(:string) - Defaults to"hero-inbox".title(:string) (required)
Slots
inner_blockactions
The file field of a LiveView upload (allow_upload/3), laid out as
<.input> lays out the other fields: the label above, the help below,
then what is wrong with the file. errors gives the words for an upload
error (:too_large, :not_accepted, :too_many_files).
<.file_input upload={@uploads.logo} label="Logo" help="An SVG file." errors={@upload_errors} />Attributes
upload(Phoenix.LiveView.UploadConfig) (required)label(:string) (required)help(:string) - Defaults tonil.errors(:map) - Defaults to%{}.class(:any) - Defaults tonil.
A flash notice, at the top right; a click dismisses it.
<.flash kind={:info} flash={@flash} />Attributes
id(:string) - the optional id of flash container.flash(:map) - the map of flash messages to display. Defaults to%{}.title(:string) - Defaults tonil.kind(:atom) - used for styling and flash lookup. Must be one of:info, or:error.- Global attributes are accepted. the arbitrary HTML attributes to add to the flash container.
Slots
inner_block- the optional inner block that renders the flash message.
@spec format_time(DateTime.t(), :day | :minute | :second) :: String.t()
A time as timestamp/1 writes it: 2026-11-08 14:03 UTC.
The heading of a page: its title, a line under it, and the page's own actions on the right.
Attributes
id(:string) - Defaults tonil.
Slots
inner_block(required)subtitleactions
A Heroicon: hero-<name> (outline, 24 px),
-solid, -mini (20 px) or -micro (16 px). Size and colour come from
class. Decorative: give the element around it a label when the icon
alone carries meaning.
<.icon name="hero-x-mark" />
<.icon name="hero-arrow-path" class="ml-1 size-3 motion-safe:animate-spin" />Attributes
name(:string) (required)class(:any) - Defaults to"size-4".
An input with its label, help and errors. A Phoenix.HTML.FormField
gives the name, id, value and errors.
type="select" takes options (and prompt); type="checkbox" is for
one boolean; help is a sentence under the field.
<.input field={@form[:email]} type="email" label="Address" />
<.input field={@form[:role]} type="select" label="Role" options={@roles} />Attributes
id(:any) - Defaults tonil.name(:any)label(:string) - Defaults tonil.help(:string) - Defaults tonil.value(:any)type(:string) - Defaults to"text". Must be one of"checkbox","color","date","datetime-local","email","file","month","number","password","search","select","tel","text","textarea","time","url","week", or"hidden".field(Phoenix.HTML.FormField) - a form field struct retrieved from the form, for example: @form[:email].errors(:list) - Defaults to[].checked(:boolean) - the checked flag for checkbox inputs.prompt(:string) - the prompt for select inputs. Defaults tonil.options(:list) - the options to pass to Phoenix.HTML.Form.options_for_select/2.multiple(:boolean) - the multiple flag for select inputs. Defaults tofalse.class(:any) - classes for the field's wrapper (its width, say). Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["accept", "autocomplete", "capture", "cols", "disabled", "form", "list", "max", "maxlength", "min", "minlength", "multiple", "pattern", "placeholder", "readonly", "required", "rows", "size", "step", "inputmode"].
A list of facts: a term and its value per row.
<.list>
<:item title="Retention">30 days</:item>
</.list>Attributes
id(:string) - Defaults tonil.
Slots
item(required) - Accepts attributes:title(:string) (required)
The sign that a page updates by itself (KartaWeb.LiveUpdates): "Live",
in a panel's header. It shows only while the page is connected (the
phx-connected class LiveView puts on the page), so it goes when the
connection is lost.
Attributes
id(:string) (required)
Links to the pages next to a page of Karta.Pager: to makes the path
of a page from its cursor (%{"before" => id} or %{"after" => id}),
with ~p and the page's own route. Nothing when there is only one page.
Examples
<.pager id="pages" page={@page} to={fn cursor -> ~p"/things?#{cursor}" end} />Attributes
id(:string) (required)page(Karta.Pager.Page) (required)to(:any) (required) - a function from the cursor parameters to a path.
A section of a page: a titled surface. flush drops the inner padding,
for a table that fills it.
<.panel id="dkim" title="DKIM keys">
<:actions><.button size="sm">Generate</.button></:actions>
...
</.panel>Attributes
id(:string) - Defaults tonil.title(:string) - Defaults tonil.flush(:boolean) - Defaults tofalse.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block(required)subtitleactions
A secret shown once (a new API key, a new password, a webhook's signing
secret): the value with a copy button, why it will not be shown again,
and the action that drops it (actions). kept says how Karta keeps
it: "hash" (the default: it can check the secret but not show it) or
"encrypted" (it needs the secret itself, to sign with). Render it only
while the page holds the secret.
Attributes
id(:string) (required)title(:string) (required)value_id(:string) (required)value(:string) (required)kept(:string) - Defaults to"hash". Must be one of"hash", or"encrypted".
Slots
inner_blockactions
A number to take in at a glance, with what it counts. tone colours the
icon only; the number stays in the text colour.
<.stat id="delivered" label="Delivered" value={120} icon="hero-check" tone="ok" />Attributes
id(:string) (required)label(:string) (required)value(:integer) (required)icon(:string) - Defaults tonil.tone(:string) - Defaults to"neutral". Must be one of"neutral","ok","warn","bad","info", or"violet".
The state of a record as a badge: a recipient or a delivery attempt
(:queued, :deferred, :delivered, :bounced, :suppressed), a
received message's delivery (:pending, :delivered, :failed,
:accepted when it was only stored, :held when it is held), a
server (:active, :suspended), a credential (:active, :revoked), a
domain (:verified, :unverified), a DKIM key (:pending, :active,
:retiring, :retired), a tracking host (:pending before its first
check, :verified, :unverified), a tracking event (:open,
:click), a DNS check and its findings (:pass, :warn, :fail,
:missing; :pending before its first result), a webhook (:on,
:off, :failing while its requests fail, :stopped when Karta switched
it off because they kept failing), a report run (:pending, :done,
:skipped, :failed), a received report (:parsed, the
report was read, :failed), a webhook delivery (:pending,
:retrying after a failed request, :succeeded, :failed). An IP
pool's address is :held_here on the node serving the page and
:not_here on another. With count, the words are "3 delivered".
<.state value={:deferred} />
<.state value={:delivered} count={2} />Attributes
id(:string) - Defaults tonil.value(:atom) (required)count(:integer) - Defaults tonil.
The words for a state, as state/1 shows them (for selects and text).
A table: dense rows, a sticky header, horizontal scrolling on narrow
screens. rows may be a list or a stream (@streams.name); id is the
tbody's. A column's class aligns it (text-right for numbers) or
sets its font (font-mono for identifiers).
<.table id="servers" rows={@servers}>
<:col :let={server} label="Name">{server.name}</:col>
<:col :let={server} label="Messages" class="text-right">{server.count}</:col>
</.table>Attributes
id(:string) (required)rows(:list) (required)row_id(:any) - the function for generating the row id. Defaults tonil.row_click(:any) - the function for handling phx-click on each row. Defaults tonil.row_class(:any) - a function giving a row's extra classes from its item (a changed row's highlight). Defaults tonil.row_item(:any) - the function for mapping each row before calling the :col and :action slots. Defaults to&Function.identity/1.
Slots
col(required) - Accepts attributes:label(:string)class(:any)
action- the slot for showing user actions in the last table column.
A time, in UTC, in a <time> element. precision is :minute (the
default), :second or :day. Nothing for nil.
Attributes
at(:any) (required)precision(:atom) - Defaults to:minute. Must be one of:day,:minute, or:second.
Translates an error message using gettext.
Translates the errors for a field from a keyword list of errors.