Skip to content

From shadcn/ui to Alpina

Start with one screen that already has a keyboard or form-submission test. A button, a labeled field and a table of amounts make a good first slice. Port their behavior while keeping the rest of the application on its existing components.

The edition-label comparison on the homepage runs the same form in both libraries. Edit the name, submit it and compare the resulting label. Each code panel copies the source used to render its own preview. The shadcn example uses the New York registry's default native Button and Input. Try the two forms · Upstream source.

Install alongside shadcn/ui

Install Alpina UI from npm in your React project. Release candidates are published under the next tag. If your team edits component source, the CLI can copy selected TypeScript, CSS and dependencies into components/alpina. Your existing shadcn/ui source can stay in components/ui. Installation guide

npm install alpina-ui@next
# Optional editable source for the first screen
npx --no-install alpina add button field input

With package imports, load alpina-ui/styles.css once. A screen can import a local shadcn/ui component and an Alpina component under different names. With copied files, use their local module paths and import the copied theme. Source-copy workflow

Reuse Tailwind v4 utilities

Add the theme bridge when you are ready to switch the appearance of semantic utility classes across the application. In the global CSS compiled by Tailwind v4, use this order.

@import "tailwindcss";
@import "alpina-ui/styles.css";
@import "alpina-ui/tailwind.css";

An existing bg-background text-foreground surface now reads Alpina's paper and ink. bg-primary text-primary-foreground uses the action color and its foreground. A gap-3 spans three grid units, 12 px with Alpina's default of 4 px. Use text-body and text-heading for the body and section-heading scales. Add alpina-ui/fonts.css if the project should serve the optional Inter family itself. Tailwind v4 theme variables · Alpina type and grid measurements

If the app already declares the same --color-* aliases in a shadcn/ui @theme inline block, choose which declarations should control those names. A later declaration of a shared alias can override the bridge. For a gradual visual rollout, import only the component styles initially and add the bridge after auditing utilities used on the remaining screens. Connect an existing dark-mode preference to data-al-theme="dark" on the root or the migrated subtree. shadcn/ui theming

Port one interaction

Here the application keeps its router and native form controls. The link receives Alpina's button styling directly. Render these fields inside the existing form so its submit handler can continue reading email from the form data.

import { Link } from "react-router"
import { Button, Field, Input, Stack } from "alpina-ui"

export function ContactFields() {
  return (
    <Stack gap={4} align="start">
      <Field label="Email address">
        {control => <Input {...control} name="email" type="email" autoComplete="email" required />}
      </Field>
      <Button asChild variant="outline">
        <Link to="/contacts">Back to contacts</Link>
      </Button>
    </Stack>
  )
}

For a Next.js application, import Link from next/link and pass href="/contacts" to it. For custom link components, forward received props, children and the ref to the actual anchor. Check that the destination still opens in a new tab, the label still focuses its input, and an empty submission still reaches the expected validation state.

Component-by-component migration

These 66 families follow the project's recorded shadcn/ui component index. Each Alpina reference includes the actual preview, prop types and editable source. The porting column highlights the API or interaction to check first. Original component index

shadcn/ui familyAlpina referenceWhat to change or verify
AccordionAccordionSupply an array of stable values, headings and panels through items. Track the open section as one string or null.
AlertAlertPass the heading as title, the body as children and the intended severity as tone.
Alert DialogAlertDialogMove the prompt, description, cancel label and confirm label onto AlertDialog. Keep the mutation in onConfirm.
Aspect RatioAspectRatioPass a numeric width-to-height ratio and choose fit="contain" for images that must remain fully visible.
AttachmentAttachmentProvide href, filename and an optional detail. Keep upload progress and file-management actions in the application.
AvatarAvatarSupply a person’s name and optional image src. Alpina derives the fallback initials.
BadgeBadgeMap the semantic state to tone. Set asChild when the badge itself is a link.
BreadcrumbBreadcrumbBuild an items array with labels and destinations. Use an item’s asChild flag for a router link and currentIndex for the active crumb.
BubbleBubblePut message content in children and choose the logical side for the speaker.
ButtonButtonUse primary for the main action and danger for destructive actions. A router link can be the root through asChild.
Button GroupButtonGroupWrap the existing actions in ButtonGroup, supply a group label and set orientation when they run vertically.
CalendarCalendarKeep the chosen civil date as an ISO YYYY-MM-DD string. Map a single selected day and its allowed bounds to value, min and max.
CardCardCompose CardHeader, CardTitle, CardDescription, CardContent and CardFooter. Choose the heading level with CardTitle as.
CarouselCarouselPass slides as items with stable values and content. Supply localized previous and next button labels.
ChartChartPass labeled numeric values to the bar chart. Keep a specialist chart renderer for series, axes or chart types your screen requires.
CheckboxCheckboxRead the boolean from event.currentTarget.checked in onChange. Use the indeterminate prop for mixed selection.
Code BlockCodeBlockPass the snippet as code and the header as label. Keep syntax highlighting, line selection and diffing with the existing editor when needed.
CollapsibleCollapsibleMove the trigger label to summary and keep the panel in children. Native details exposes open state through the toggle event.
ComboboxComboboxPass searchable options, a label and an empty message. Store the selected option’s string value with onValueChange.
CommandCommandDescribe commands in items. Translate the dialog title, search label, empty state and close action.
Context MenuContextMenuWrap the invocation region in ContextMenu. Configure each action in items and handle the chosen value in onValueSelect.
Data TableDataTableSupply rows, typed columns, rowKey, caption and empty. Use format: 'chf', 'decimal' or 'swiss-date' for built-in sorting. Custom cells accept a compare function. Keep app filtering and paging in the parent.
Date PickerDatePickerUse the calendar’s single ISO-date value. Pass name for form submission and clearable when a date is optional.
DialogDialogMove the title, trigger, close label and footer onto the dialog. Pass the panel body as children and retain open / onOpenChange for controlled state.
DirectionDirectionWrap the text region with dir="rtl", "ltr" or "auto". Logical layout then follows the chosen writing direction.
DrawerDrawerSupply the modal title, body and close label. Use swipeToClose to configure the bottom drawer gesture.
Dropdown MenuDropdownMenuMove actions into items. Compose a router link as a slotted item and add textValue when its accessible content needs a shorter typeahead label.
EmptyEmptyPass a short title, optional description and recovery action. Use titleAs to match the page outline.
FieldFieldUse the field’s child function to spread its generated ID and description attributes onto the actual control.
Hover CardHoverCardSupply the trigger and card title as props and place the preview in children. Keep essential destinations reachable through an ordinary link.
InputInputKeep native type, value, onChange, name and validation props. numeric aligns numeric input.
Input GroupInputGroupPlace the input in children and put affixes or actions in leading and trailing.
Input OTPInputOTPStore the entire code as a string. Set length and use onValueChange to preserve leading zeroes and native paste.
ItemItemPut the primary label in title and use description, leading and trailing for supporting content.
KbdKbdPlace the literal key or shortcut text in Kbd. Implement the actual shortcut in the application.
LabelLabelSet htmlFor to the native control ID. Use Field if the control also needs help or error text.
MarkerMarkerMap the state to open, closed or attention, and supply text describing what the sign means.
MenubarMenubarDescribe each top-level group in menus and its commands in items. Keep application actions in the selection callbacks.
MessageMessagePass author, timestamp and dateTime to identify the sender and time. Put the message body in children.
Message ScrollerMessageScrollerPlace messages in the scrolling log and provide jumpLabel for returning to the latest message. Test any retained transcript-loading behavior separately.
Native SelectNativeSelectPass ordinary HTML options and native selection events. appearance="line" selects the underlined presentation.
Navigation MenuNavigationMenuUse labeled sections of links. Give router entries their route identity in href and their link element in label with asChild.
PaginationPaginationBuild numbered items with real URLs. Set currentPage and provide pageLabel for translated accessible names.
PopoverPopoverSupply a title, trigger, close label and panel children. Use onOpenChange to synchronize controlled state.
ProgressProgressPass a numeric value and optional max. Omit value for indeterminate progress and supply the accessible label.
QuestionnaireQuestionnaireBuild questions with IDs and single-choice options. Consume reviewed answers in onComplete; keep multi-select and free text in a different form.
Radio GroupRadioGroupPass the group label and option array. Use onValueChange for its single value and name for native form submission.
ResizableResizableProvide two panes through first and second. Configure the split with orientation, min, max and step.
Scroll AreaScrollAreaGive the region a label and set its maxHeight. Put the scrollable content directly in children.
SelectSelectUse native <option> children and read the selected value in onChange. Use Combobox for type-to-search selection.
SeparatorSeparatorUse orientation for the axis and weight="section" for a stronger rule. Set decorative={false} when the boundary conveys structure.
SheetSheetPass a logical side of start or end, a modal title and a close label. Put editing controls in children.
SidebarSidebarSupply the masthead, tools, scrollable children and optional footer. Pair it with AppShell for a collapsible mobile index.
SkeletonSkeletonChoose the text, block or avatar placeholder shape and reserve space close to the incoming content.
SliderSliderUse the native range input’s numeric min, max and step. Read one value with event.currentTarget.valueAsNumber.
SpinnerSpinnerSupply a label when loading should be announced; use showLabel to display that text beside the spinner.
SwitchSwitchUse a native checked boolean and onChange. Add stateLabels to show translated on/off text.
TableTableCompose the table parts directly and mark comparable amount cells numeric for end alignment and tabular figures.
TabsTabsDescribe each panel in items. Choose automatic or manual activation and manage the active tab through value and onValueChange.
TextareaTextareaKeep native textarea props for editing, submission and form reset. Opt in to autoGrow where height should follow content.
ToastToastRender a controlled notification with open, onOpenChange and closeLabel. Mount one Toaster for app-wide messages sent with toast(message).
ToggleToggleUse pressed and onPressedChange. Keep the action’s label stable so its pressed state identifies the change.
Toggle GroupToggleGroupDescribe choices in options and store selected values in an array. Use multiple for independent choices or layout="grid" for a tile picker.
TooltipTooltipPass a focusable child element and short content text. Keep the existing control’s accessible name.
TraceTracePass ordered events with IDs, titles and optional detail. Use the detail disclosure for an event’s expanded explanation.
TypographyTypographyUse as for the semantic element and variant for the visual role. Apply numeric to comparable figures.

Differences to consider

FamilyDocumented behavior
AttachmentAlpina links to a file with its metadata or collects a local attachment in upload mode. shadcn/ui also composes media previews, upload progress, and independent actions. shadcn/ui Attachment
BubbleAlpina places content at the start or end of a conversation row. shadcn/ui also documents bubble groups, reactions, and collapsible text. shadcn/ui Bubble
MarkerAlpina places a sign beside text to distinguish three states. shadcn/ui also uses this family for system notes, bordered rows, and labeled separators in a conversation. shadcn/ui Marker
MessageAlpina composes an article with an author, optional time, and bubble. shadcn/ui provides dedicated parts for the avatar, header, footer, and alignment. shadcn/ui Message
Message ScrollerAlpina follows new messages and offers a return to the bottom for readers browsing earlier messages. shadcn/ui also documents per-turn anchoring, transcript restoration, prepending history, and jumping to a specific message. shadcn/ui Message Scroller
QuestionnaireAlpina handles a sequence of required single-choice questions with review and submission. shadcn/ui also offers multiple selection, free-form answers, and skippable questions. shadcn/ui Questionnaire
TraceAlpina presents an ordered timeline with times and expandable details. shadcn/ui Trace parts also compose tool calls, sources, and incremental agent updates. shadcn/ui Trace
Code BlockAlpina displays and copies a string with a header. shadcn/ui also documents line numbers, diffs, and terminal output. shadcn/ui Code Block
ChartAlpina plots bars for positive and negative values and includes the underlying data table. The shadcn/ui Recharts integration offers additional chart families. shadcn/ui Chart
Data TableAlpina sorts Swiss dates and amounts, groups rows with subtotals, prints repeated headings, and accepts custom cells. The shadcn/ui guide builds on TanStack Table and also covers filtering, pagination, and column visibility. shadcn/ui Data Table
Calendar and Date PickerAlpina selects one civil date at a time in the four Swiss national languages and returns an ISO date value. The shadcn/ui documentation also covers date ranges. shadcn/ui Calendar
Select and Native SelectBoth Alpina entries use an HTML select with a styled popup and native keyboard navigation. The shadcn/ui Select family describes a composite control with a trigger and list. shadcn/ui Select
SliderAlpina uses a single-value HTML slider. shadcn/ui also documents a slider with multiple thumbs. shadcn/ui Slider

The 32 additional entries in Alpina 1.0.0-rc.7

PurposeAlpina entries
Layout and portalapp-shell, figure, grid, grid-overlay, stack, prose, text-link
SVG data graphicsbar-chart, line-chart, sparkline, chart-table
Interface symbolsicon
Read-only summaries and workflowsdescription-list, steps
Language, cantons, and addressescanton-combobox, canton-select, locale-select, multilingual-field, swiss-address-form, swiss-locality-combobox, swiss-postal-code-input
File selectionfile-input
Formattingcurrency-chf, swiss-date
Printable documentsletter, invoice-document
Payments and identifiersswiss-qr-bill, qr-bill-scanner, iban-input, ahv-input, phone-input, uid-input

The QR-bill checks its account, reference and currency combination before encoding a payment. The four identifier inputs check telephone number structure or the check digits of an IBAN, AHV or business UID. A checksum does not establish registration or ownership. The grid overlay provides visual inspection independently of the modular grid used to lay out an application. QR-bill printing · Swiss forms and formatting