Matter’s components are the controls Matter itself uses, rewritten for apps: buttons, inputs, checkboxes, switches, selects, menus, popovers, tooltips, dialogs, badges and avatars. They’re React components on Base UI and Tailwind, styled with Matter’s theme, so they follow light, dark and wallpaper mode.
They live in your project, not in a package. A project from matter app create starts with all
of them in src/components/ui/. Change them as you like: a new version of Matter never changes
your copy, and a deploy ships the components it was built with.
Adding Components#
Matter publishes its components as a shadcn registry, and
the starter’s components.json names it @matter. To add one back after deleting it,
or replace yours with Matter’s latest:
npx shadcn@latest add @matter/menu
Without the @matter/ prefix, shadcn adds its own component of that name instead. Other shadcn
components work too, and use the same theme.
For a project that didn’t start from the starter, add React, Tailwind (@tailwindcss/vite) and
the @/ alias for src/, then add @matter/theme and import
src/matter.css from your entry point.
The Components#
| Name | What it exports |
|---|---|
button |
Button, in variants default, outline, secondary,
ghost, destructive and link, and sizes from xs to
lg and icon.
|
input |
Input, Textarea, and Field for a label above either. |
checkbox |
Checkbox, whose check strokes itself in. |
switch |
Switch, in sizes sm, md and lg. |
select |
Select, a choice of one from a list of options. |
menu |
DropdownMenu and ContextMenu, with MenuItem,
MenuCheckboxItem, SubMenu, MenuSeparator and
MenuLabel.
|
popover |
Popover, PopoverTitle and PopoverClose. |
tooltip |
Tooltip, and TooltipProvider, which the starter puts around the page. |
dialog |
Dialog, DialogHeader, DialogBody and
DialogActions.
|
badge |
Badge, in tones neutral, primary, success,
warning and destructive.
|
avatar |
Avatar: a member’s photo or initial, from their id. |
An Example#
import { useState } from 'react'
import { Pencil, Trash2 } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Dialog, DialogActions, DialogBody, DialogHeader } from '@/components/ui/dialog'
import { Field, Input } from '@/components/ui/input'
import { DropdownMenu, MenuItem, MenuSeparator } from '@/components/ui/menu'
import { Switch } from '@/components/ui/switch'
export function DealActions({ name }: { name: string }) {
const [renaming, setRenaming] = useState(false)
const [watching, setWatching] = useState(false)
return (
<div className="flex items-center gap-3">
<label className="flex items-center gap-2 text-sm">
<Switch checked={watching} onCheckedChange={setWatching} /> Watch
</label>
<DropdownMenu trigger={<Button variant="outline">Actions</Button>}>
<MenuItem icon={<Pencil />} label="Rename" onClick={() => setRenaming(true)} />
<MenuSeparator />
<MenuItem icon={<Trash2 />} label="Delete" danger />
</DropdownMenu>
<Dialog open={renaming} onOpenChange={setRenaming}>
<DialogHeader title="Rename deal" />
<DialogBody>
<Field label="Name">
<Input defaultValue={name} />
</Field>
</DialogBody>
<DialogActions>
<Button variant="ghost" onClick={() => setRenaming(false)}>Cancel</Button>
<Button>Rename</Button>
</DialogActions>
</Dialog>
</div>
)
}