Skip to main content

Button

import { button, buttonGroup } from '@frontmcp/ui';

button(label, options?)

Creates a button element.
ParameterTypeDescription
labelstringButton text content
optionsButtonOptionsConfiguration options

ButtonOptions

PropertyTypeDefaultDescription
variant'primary' | 'secondary' | 'outline' | 'ghost' | 'danger' | 'link''primary'Visual style
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Button size
disabledbooleanfalseDisable interactions
loadingbooleanfalseShow loading spinner
fullWidthbooleanfalseStretch to container width
type'button' | 'submit' | 'reset''button'HTML button type
idstring-DOM element ID
classNamestring-Additional CSS classes
dataRecord<string, string>-Data attributes
htmxHtmxOptions-HTMX attributes
// Basic
button('Click me');

// With options
button('Submit', {
  variant: 'primary',
  size: 'lg',
  type: 'submit',
});

// With HTMX
button('Load More', {
  htmx: {
    get: '/api/items?page=2',
    target: '#items',
    swap: 'beforeend',
  },
});

buttonGroup(buttons, options?)

Groups multiple buttons together.
PropertyTypeDefaultDescription
direction'horizontal' | 'vertical''horizontal'Layout direction
gap'xs' | 'sm' | 'md' | 'lg''sm'Spacing between buttons
align'start' | 'center' | 'end''start'Alignment

Preset Buttons

import {
  primaryButton,
  secondaryButton,
  outlineButton,
  ghostButton,
  dangerButton,
  linkButton,
} from '@frontmcp/ui';

// Each accepts (label, options?) and pre-applies the variant
primaryButton('Save');    // variant: 'primary'
dangerButton('Delete');   // variant: 'danger'

Card

import { card, cardGroup } from '@frontmcp/ui';

card(content, options?)

Creates a card container.
ParameterTypeDescription
contentstringCard body content (HTML)
optionsCardOptionsConfiguration options

CardOptions

PropertyTypeDefaultDescription
titlestring-Card header title
subtitlestring-Header subtitle
footerstring-Footer content (HTML)
variant'default' | 'outline' | 'elevated' | 'ghost''default'Visual style
size'sm' | 'md' | 'lg''md'Padding size
noPaddingbooleanfalseRemove body padding
classNamestring-Additional CSS classes
card('<p>Card content</p>', {
  title: 'Card Title',
  subtitle: 'A brief description',
  footer: '<button>Action</button>',
  variant: 'elevated',
});

cardGroup(cards, options?)

Groups cards in a grid layout.
PropertyTypeDefaultDescription
cols1 | 2 | 3 | 42Number of columns
gap'sm' | 'md' | 'lg''md'Gap between cards

Badge

import { badge, badgeGroup } from '@frontmcp/ui';

badge(label, options?)

Creates a badge/tag element.
ParameterTypeDescription
labelstringBadge text
optionsBadgeOptionsConfiguration options

BadgeOptions

PropertyTypeDefaultDescription
variant'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info''default'Color variant
size'xs' | 'sm' | 'md' | 'lg''md'Badge size
rounded'sm' | 'md' | 'lg' | 'full''full'Border radius
dotbooleanfalseShow as status dot
removablebooleanfalseShow remove button
classNamestring-Additional CSS classes
badge('New', { variant: 'success' });
badge('Beta', { variant: 'warning', size: 'sm' });

Preset Badges

import {
  activeBadge,
  inactiveBadge,
  pendingBadge,
  errorBadge,
  newBadge,
  betaBadge,
} from '@frontmcp/ui';

// Status badges
activeBadge();    // Green "Active"
pendingBadge();   // Yellow "Pending"
errorBadge();     // Red "Error"

Status Dots

import { onlineDot, offlineDot, busyDot, awayDot } from '@frontmcp/ui';

onlineDot();   // Green dot
offlineDot();  // Gray dot
busyDot();     // Red dot
awayDot();     // Yellow dot

Alert

import { alert, toast, toastContainer } from '@frontmcp/ui';

alert(message, options?)

Creates an alert/banner element.
ParameterTypeDescription
messagestringAlert content (HTML)
optionsAlertOptionsConfiguration options

AlertOptions

PropertyTypeDefaultDescription
variant'info' | 'success' | 'warning' | 'danger' | 'neutral''info'Visual style
titlestring-Alert heading
showIconbooleantrueShow variant icon
iconstring-Custom icon HTML
dismissiblebooleanfalseShow close button
classNamestring-Additional CSS classes
idstring-Alert ID
actionsstring-HTML for action buttons
onDismissHtmxOptions-HTMX options for dismiss
alert('Operation completed successfully', {
  variant: 'success',
  title: 'Success',
  dismissible: true,
});

Preset Alerts

import { infoAlert, successAlert, warningAlert, dangerAlert } from '@frontmcp/ui';

successAlert('Saved!');
dangerAlert('Error occurred', { title: 'Error' });

toast(message, options?)

Creates a toast notification.

ToastOptions

PropertyTypeDefaultDescription
variantAlertVariant'info'Visual style
titlestring-Toast heading
durationnumber5000Auto-dismiss ms (0 = no auto-dismiss)
position'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center''top-right'Screen position
idstringauto-generatedToast ID
dismissiblebooleantrueShow close button

toastContainer(position?)

Creates a container for toast notifications.

Form Components

import { input, select, textarea, checkbox, radioGroup, form } from '@frontmcp/ui';

input(options)

Creates a text input field.

InputOptions

PropertyTypeDefaultDescription
type'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'search' | 'date' | 'time' | 'datetime-local''text'Input type
namestring-Field name
valuestring-Initial value
placeholderstring-Placeholder text
labelstring-Associated label
hintstring-Help text
errorstring-Error message
requiredbooleanfalseRequired field
disabledbooleanfalseDisabled state
readonlybooleanfalseRead-only state
size'sm' | 'md' | 'lg''md'Input size
state'default' | 'error' | 'success''default'Validation state
prefixstring-Text/icon before input
suffixstring-Text/icon after input
htmxHtmxOptions-HTMX attributes
input({
  type: 'email',
  name: 'email',
  label: 'Email Address',
  placeholder: '[email protected]',
  required: true,
});

select(options)

Creates a select dropdown.

SelectOptions

PropertyTypeDefaultDescription
namestring-Field name
optionsSelectOption[][]Dropdown options
valuestring-Selected value
placeholderstring-Placeholder option
labelstring-Associated label
multiplebooleanfalseMulti-select
size'sm' | 'md' | 'lg''md'Select size
interface SelectOption {
  value: string;
  label: string;
  disabled?: boolean;
}

select({
  name: 'country',
  label: 'Country',
  options: [
    { value: 'us', label: 'United States' },
    { value: 'uk', label: 'United Kingdom' },
  ],
});

textarea(options)

Creates a textarea element.

TextareaOptions

PropertyTypeDefaultDescription
namestring-Field name
valuestring-Initial value
placeholderstring-Placeholder text
labelstring-Associated label
rowsnumber4Visible rows
resize'none' | 'vertical' | 'horizontal' | 'both''vertical'Resize behavior

checkbox(options)

Creates a checkbox input.

CheckboxOptions

PropertyTypeDefaultDescription
namestring-Field name
labelstring-Checkbox label
checkedbooleanfalseInitial state
valuestring-Checkbox value
disabledbooleanfalseDisabled state

radioGroup(options)

Creates a group of radio buttons.

RadioGroupOptions

PropertyTypeDefaultDescription
namestring-Field name (shared)
optionsSelectOption[][]Radio options
valuestring-Selected value
direction'horizontal' | 'vertical''vertical'Layout

form(content, options?)

Wraps content in a form element.

FormOptions

PropertyTypeDefaultDescription
actionstring-Form action URL
method'get' | 'post''post'HTTP method
idstring-Form ID
classNamestring-Additional CSS classes
htmxHtmxOptions-HTMX form handling

Form Layout Helpers

import { formRow, formSection, formActions, hiddenInput, csrfInput } from '@frontmcp/ui';

// Group fields horizontally
formRow([input1, input2]);

// Section with heading
formSection('Contact Info', fields);

// Action buttons (right-aligned)
formActions([cancelBtn, submitBtn]);

// Hidden fields
hiddenInput('id', '123');
csrfInput('token-value');

Table

import { table, pagination } from '@frontmcp/ui';

table(options)

Creates a data table.

TableOptions

PropertyTypeDefaultDescription
columnsTableColumn[][]Column definitions
dataRecord<string, unknown>[][]Row data
stripedbooleanfalseStriped rows
hoverbooleantrueRow hover effect
borderedbooleanfalseCell borders
compactbooleanfalseReduced padding
captionstring-Table caption
emptyMessagestring'No data'Empty state message

TableColumn

PropertyTypeDescription
keystringData property key
headerstringColumn header text
align'left' | 'center' | 'right'Text alignment
widthstringColumn width (CSS)
sortablebooleanEnable sorting
render(value, row) => stringCustom cell renderer
table({
  columns: [
    { key: 'name', header: 'Name', sortable: true },
    { key: 'email', header: 'Email' },
    {
      key: 'status',
      header: 'Status',
      render: (value) => badge(value, { variant: value === 'active' ? 'success' : 'default' }),
    },
  ],
  data: users,
  striped: true,
});

pagination(options)

Creates pagination controls.

PaginationOptions

PropertyTypeDefaultDescription
totalnumber-Total items
pagenumber1Current page
pageSizenumber10Items per page
baseUrlstring-URL template
htmxHtmxOptions-HTMX navigation

List

import { descriptionList, actionList, permissionList, featureList } from '@frontmcp/ui';

descriptionList(items, options?)

Creates a term/description list.
interface DescriptionItem {
  term: string;
  description: string;
}

descriptionList([
  { term: 'Name', description: 'John Doe' },
  { term: 'Email', description: '[email protected]' },
], { columns: 2 });

actionList(items)

Creates a list of actionable items.
interface ActionItem {
  label: string;
  description?: string;
  icon?: string;
  href?: string;
  htmx?: HtmxOptions;
}

actionList([
  { label: 'Settings', icon: 'cog', href: '/settings' },
  { label: 'Logout', icon: 'sign-out', htmx: { post: '/logout' } },
]);

permissionList(items)

Creates a permission checklist.
interface PermissionItem {
  name: string;
  granted: boolean;
  description?: string;
}

permissionList([
  { name: 'Read access', granted: true },
  { name: 'Write access', granted: false },
]);

featureList(items)

Creates a feature comparison list.
interface FeatureItem {
  name: string;
  included: boolean;
}

featureList([
  { name: 'Unlimited projects', included: true },
  { name: 'Priority support', included: false },
]);

Avatar

import { avatar, avatarGroup, avatarWithText } from '@frontmcp/ui';

avatar(options)

Creates an avatar element.

AvatarOptions

PropertyTypeDefaultDescription
srcstring-Image URL
altstring''Alt text
initialsstring-Fallback initials
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Avatar size
shape'circle' | 'square''circle'Shape
status'online' | 'offline' | 'busy' | 'away'-Status indicator
avatar({
  src: '/user.jpg',
  alt: 'John Doe',
  size: 'lg',
  status: 'online',
});

avatar({
  initials: 'JD',
  size: 'md',
});

avatarGroup(avatars, options?)

Groups multiple avatars with overlap.

AvatarGroupOptions

PropertyTypeDefaultDescription
maxnumber-Max visible (shows +N)
sizeAvatarSize'md'Size for all
spacing'tight' | 'normal''normal'Overlap amount

avatarWithText(options)

Avatar with name and optional subtitle.

AvatarWithTextOptions

PropertyTypeDescription
avatarAvatarOptionsAvatar config
namestringPrimary text
subtitlestringSecondary text

import { modal, modalTrigger, confirmModal, drawer } from '@frontmcp/ui';
Creates a modal dialog.

ModalOptions

PropertyTypeDefaultDescription
idstringrequiredModal ID
titlestring-Modal title
size'sm' | 'md' | 'lg' | 'xl' | 'full''md'Modal width
closablebooleantrueShow close button
footerstring-Footer content
modal('<p>Modal content</p>', {
  id: 'my-modal',
  title: 'Confirm Action',
  footer: button('Confirm', { variant: 'primary' }),
});

modalTrigger(targetId, trigger)

Creates a button that opens a modal.
modalTrigger('my-modal', button('Open Modal'));

confirmModal(options)

Creates a confirmation dialog.

ConfirmModalOptions

PropertyTypeDescription
idstringModal ID
titlestringDialog title
messagestringConfirmation message
confirmTextstringConfirm button text
cancelTextstringCancel button text
confirmVariantButtonVariantConfirm button style
onConfirmHtmxOptionsConfirm action

drawer(content, options)

Creates a slide-out drawer.

DrawerOptions

PropertyTypeDefaultDescription
idstringrequiredDrawer ID
titlestring-Drawer title
position'left' | 'right' | 'top' | 'bottom''right'Slide direction
size'sm' | 'md' | 'lg''md'Drawer width

HTMX Options

All interactive components accept an htmx property for server-driven updates.

HtmxOptions

PropertyTypeDescription
getstringGET request URL
poststringPOST request URL
putstringPUT request URL
deletestringDELETE request URL
patchstringPATCH request URL
targetstringCSS selector for target
swap'innerHTML' | 'outerHTML' | 'beforeend' | 'afterend' | 'beforebegin' | 'afterbegin' | 'delete' | 'none'Swap strategy
triggerstringEvent trigger
indicatorstringLoading indicator selector
confirmstringConfirmation message
valsRecord<string, string>Additional values
headersRecord<string, string>Request headers
button('Delete', {
  htmx: {
    delete: '/api/items/123',
    target: '#item-123',
    swap: 'outerHTML',
    confirm: 'Are you sure?',
  },
});

Zod Schemas

All components export Zod schemas for runtime validation.
import {
  ButtonOptionsSchema,
  CardOptionsSchema,
  BadgeOptionsSchema,
  AlertOptionsSchema,
  InputOptionsSchema,
  SelectOptionsSchema,
  TableOptionsSchema,
  AvatarOptionsSchema,
  ModalOptionsSchema,
} from '@frontmcp/ui';

// Validate options
const result = ButtonOptionsSchema.safeParse(userInput);
if (!result.success) {
  console.error(result.error);
}
Invalid options render a styled error box instead of the component:
<div class="validation-error" data-component="button" data-param="variant">
  Invalid property "variant" in button component
</div>