` behave like a control when a native element is appropriate.
+
+## Accessibility conventions
+
+Accessibility is part of the component API and implementation.
+
+- Every form control needs a visible label unless the component has a justified alternative accessible name.
+- Keep help and error text connected with `aria-describedby` where relevant.
+- Expose invalid state with `aria-invalid` where appropriate.
+- Keep visible `:focus-visible` treatment.
+- Do not rely on color alone for selected, error, warning, or success states.
+- `IconButton` must always have an `aria-label`.
+- Decorative icons should not create duplicate accessible names.
+- Dialog and Sheet should support Escape and return focus after closing.
+- Tabs and menus should keep their keyboard navigation behavior intact.
+- Selected filter controls should expose state semantically, for example with `aria-pressed`.
+
+Shared form accessibility plumbing belongs in `internal/` rather than being reimplemented in every control.
+
+## Form-control conventions
+
+`Field`, `Select`, `Textarea`, `Checkbox`, `ToggleSwitch`, and `RadioGroup` share common label/help/error behavior through internal helpers.
+
+Use the existing internal helpers when adding comparable controls:
+
+- `internal/fieldA11y.ts` — IDs, `aria-describedby`, and invalid state.
+- `internal/FieldText.tsx` — required marker, help text, and error text.
+
+Do not manually recreate these relationships in a new form component unless the component genuinely needs different semantics.
+
+### Checkbox vs ToggleSwitch
+
+- Use `Checkbox` for form choices, agreements, and membership in a set.
+- Use `ToggleSwitch` for immediate on/off settings.
+
+### RadioGroup
+
+Use `RadioGroup` when exactly one item in a group is selected. Keep the native radio input semantics and group labelling.
+
+## Icons
+
+Raw SVG icon components live in `src/icons/`.
+
+Production UI should normally render icons through the shared abstractions:
+
+- `Icon` — shared size, tone, and stroke behavior.
+- `IconBadge` — non-interactive visual/semantic icon surface.
+- `IconButton` — icon-only interactive button.
+
+Do not embed new duplicated SVG markup inside UI components when a shared icon exists or should exist.
+
+Raw icons should use `currentColor` so parent components can control icon color.
+
+### Icon ownership of interaction
+
+`Icon` and `IconBadge` are non-interactive. Hover, active, pressed, focus, disabled, and selected interaction states belong to the semantic parent such as Button, IconButton, link, FilterChip, or menu item.
+
+### Icon-bearing component APIs
+
+When a reusable component owns icon size/tone placement, prefer accepting an icon component and rendering it through `Icon` internally rather than accepting arbitrary already-rendered SVG markup.
+
+Use arbitrary `ReactNode` icon content only when there is a real need for non-standard artwork.
+
+## Button conventions
+
+- Use `Button` when the action should have visible text.
+- Use `IconButton` for compact icon-only actions.
+- Do not duplicate button interaction styling inside DropdownMenu, Dialog, cards, or other components.
+- Destructive actions should use the established destructive/error treatment rather than custom red values.
+
+## Tag vs FilterChip
+
+- `Tag` is passive metadata.
+- `FilterChip` is interactive and selectable.
+
+Do not make Tag clickable for filtering. Use FilterChip so the selected state and button semantics remain correct.
+
+## Dialog, Sheet, and ConfirmationDialog
+
+`Dialog` and `Sheet` share common native-dialog behavior through `internal/useDialogControl.ts`.
+
+Keep that behavior centralized:
+
+- controlled open/close state,
+- `showModal()` / `close()`,
+- Escape handling,
+- optional backdrop closing,
+- generated title/description IDs,
+- focus restoration.
+
+Use:
+
+- `Dialog` for centered modal tasks and focused content.
+- `Sheet` for secondary edge/mobile surfaces such as filters.
+- `ConfirmationDialog` for standard confirm/cancel flows; it should compose Dialog and Button rather than reimplement them.
+
+## Menu and DropdownMenu
+
+Keep responsibilities distinct:
+
+- `Menu` provides the menu surface/item behavior when the caller already owns surrounding state or positioning.
+- `DropdownMenu` owns the common trigger + positioned menu pattern, including open state, outside-click closing, alignment, focus return, and compound items.
+
+Do not duplicate menu-item keyboard logic between them. Shared menu behavior belongs in the existing menu helpers.
+
+For normal recipe action menus, prefer DropdownMenu.
+
+## Feedback components
+
+Shared feedback tone behavior is defined in `internal/feedbackTone.ts`.
+
+Use the shared `success | error | warning | info` mapping for icons and semantic roles instead of recreating tone logic in Toast, FeedbackMessage, ConfirmationDialog, or future feedback components.
+
+- `FeedbackMessage` is persistent/in-flow feedback.
+- `Toast` is short-lived feedback.
+- `ConfirmationDialog` is for a decision, not passive feedback.
+
+## Controlled and uncontrolled state
+
+Components such as Tabs and DropdownMenu may support both controlled and uncontrolled usage.
+
+Reuse `internal/useControllableState.ts` rather than reimplementing this pattern.
+
+Uncontrolled:
+
+```tsx
+
...
+```
+
+Controlled:
+
+```tsx
+
+ ...
+
+```
+
+Use controlled state when a parent needs to coordinate the component with application state. Otherwise prefer the simpler uncontrolled API.
+
+## Refs
+
+Foundational controls should expose their underlying element ref when it is useful for focus management, compound components, or integrations.
+
+Prefer React 19-compatible prop typing such as `ComponentPropsWithRef<"button">` / `ComponentPropsWithRef<"input">` where it fits the component API.
+
+Do not add ref plumbing to purely presentational components without a use case.
+
+## Internal helpers
+
+Current internal helpers include:
+
+```text
+internal/
+ feedbackTone.ts
+ fieldA11y.ts
+ FieldText.tsx
+ useControllableState.ts
+ useDialogControl.ts
+```
+
+Use `internal/` for logic that:
+
+- is shared by multiple public UI components,
+- is not intended as an application-level API,
+- reduces repeated accessibility/state behavior,
+- has a clear single responsibility.
+
+Do not move ordinary one-component implementation details into `internal/` merely to make files shorter.
+
+## Showcase conventions
+
+The scrollable showcase is the primary visual documentation and responsive review tool. Preserve that workflow.
+
+When adding or changing a component:
+
+1. Add/update its showcase.
+2. Show representative variants, sizes, states, and disabled behavior.
+3. Include at least one realistic application context when useful.
+4. Include narrow-container/responsive examples for components whose layout can be constrained.
+5. Keep the catalog as one easy-to-scroll page rather than splitting every component into separate routes or Storybook stories.
+
+Use showcase-only helpers such as `ShowcaseSection` and `showcaseStyles`; do not turn them into production components.
+
+Avoid making showcase files exhaustive. The goal is quick visual review, not demonstrating every possible prop combination.
+
+## Testing conventions
+
+Keep the UI test suite deliberately small and reviewable.
+
+Prioritize tests when breaking JavaScript behavior or accessibility state could leave the component looking visually normal while behaving incorrectly.
+
+Good candidates include:
+
+- controlled selection/open state,
+- meaningful click/keyboard behavior,
+- focus restoration,
+- disabled behavior,
+- `aria-current`, `aria-pressed`, `aria-checked`, or similar state,
+- form accessibility relationships.
+
+Avoid low-value tests that only assert CSS class names, decorative markup, or that passive text renders.
+
+As a guideline, prefer roughly 1–4 focused tests per behavior-heavy component rather than trying to create a dedicated exhaustive test suite for every primitive.
+
+Do not test CSS media/container queries in jsdom. Verify responsive visual behavior in the showcase/browser.
+
+## Adding a new component
+
+Before adding one, check:
+
+1. Can an existing UI component already cover the need?
+2. Is this genuinely reusable across more than one product context, or should it be a recipe/domain component instead?
+3. Can it compose existing Button, Icon, Dialog, form, or feedback primitives rather than duplicate them?
+4. Does it need shared state/accessibility logic that belongs in `internal/`?
+5. Are existing tokens sufficient?
+6. Does it need a showcase example?
+7. Does it have enough behavior to justify a focused test?
+
+A new generic UI component should normally include:
+
+```text
+ComponentName/
+ ComponentName.tsx
+ ComponentName.css
+```
+
+plus a showcase update and, only when useful, focused tests.
+
+Do not add an `index.ts`.
+
+## When refactoring
+
+Prefer incremental refactors that preserve the public API and visual design where practical.
+
+Refactor when it improves one or more of:
+
+- consistency with tokens,
+- composition of existing UI primitives,
+- accessibility,
+- keyboard behavior,
+- duplicated state logic,
+- duplicated icon/SVG logic,
+- responsive robustness,
+- maintainability across several components.
+
+Avoid abstraction for abstraction's sake. A little duplication local to one component is often better than a generic helper with no clear reuse.
+
+## Review checklist
+
+Before considering a UI change complete, check:
+
+- [ ] Uses existing tokens where applicable.
+- [ ] Component CSS is inside `@layer components`.
+- [ ] Uses native semantics where possible.
+- [ ] Reuses existing UI components rather than duplicating them.
+- [ ] Uses shared Icon/IconButton/IconBadge behavior where relevant.
+- [ ] Keyboard/focus behavior still works.
+- [ ] Labels, help text, errors, and ARIA state are correct where relevant.
+- [ ] Disabled and destructive states are coherent with the rest of the library.
+- [ ] Does not introduce `index.ts` barrels.
+- [ ] Showcase still looks correct at wide and narrow widths.
+- [ ] Adds or updates only the tests that protect meaningful behavior.
+- [ ] `npm run lint`, `npm test`, and `npm run build` pass before delivery.
diff --git a/apps/web/src/components/ui/Sheet/Sheet.css b/apps/web/src/components/ui/Sheet/Sheet.css
new file mode 100644
index 0000000..01fb11e
--- /dev/null
+++ b/apps/web/src/components/ui/Sheet/Sheet.css
@@ -0,0 +1,232 @@
+@layer components {
+ .sheet {
+ position: fixed;
+
+ inset: auto 0 0 0;
+
+ width: 100%;
+ max-width: 42rem;
+
+ max-height: calc(100dvh - var(--space-6));
+
+ margin: 0 auto;
+ padding: 0;
+
+ color: var(--color-text-primary);
+
+ background-color: var(--color-surface);
+
+ border: var(--border-width-thin) solid var(--color-border-subtle);
+
+ border-block-end: 0;
+
+ border-radius: var(--radius-xl) var(--radius-xl) 0 0;
+
+ box-shadow: 0 -12px 32px
+ color-mix(in srgb, var(--color-shadow) 14%, transparent);
+
+ overflow: hidden;
+
+ overscroll-behavior: contain;
+ }
+
+ .sheet::backdrop {
+ background-color: var(--color-backdrop);
+
+ animation: sheet-backdrop-in var(--duration-normal) var(--ease-standard)
+ both;
+ }
+
+ .sheet[open] {
+ animation: sheet-enter var(--duration-normal) var(--ease-standard) both;
+ }
+
+ /* =========================================================
+ Handle
+ ========================================================= */
+
+ .sheet__handle-area {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+
+ height: 1.5rem;
+
+ padding-block-start: var(--space-2);
+
+ background-color: var(--color-surface);
+ }
+
+ .sheet__handle {
+ display: block;
+
+ width: 2.75rem;
+ height: 0.25rem;
+
+ background-color: var(--color-border-strong);
+
+ border-radius: var(--radius-full);
+
+ opacity: 0.7;
+ }
+
+ /* =========================================================
+ Header
+ ========================================================= */
+
+ .sheet__header {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: var(--space-4);
+
+ padding: var(--space-3) var(--space-5) var(--space-4);
+
+ background-color: var(--color-surface);
+
+ border-bottom: var(--border-width-thin) solid var(--color-border-divider);
+ }
+
+ .sheet__heading {
+ display: flex;
+ flex: 1 1 auto;
+ flex-direction: column;
+ gap: var(--space-1);
+
+ min-width: 0;
+ }
+
+ .sheet__title {
+ color: var(--color-text-primary);
+
+ font-size: var(--font-size-xl);
+
+ font-weight: var(--font-weight-bold);
+
+ line-height: var(--line-height-tight);
+ }
+
+ .sheet__description {
+ color: var(--color-text-secondary);
+
+ font-size: var(--font-size-sm);
+
+ line-height: var(--line-height-normal);
+ }
+
+ /* =========================================================
+ Body
+ ========================================================= */
+
+ .sheet__body {
+ min-height: 0;
+
+ padding: var(--space-4) var(--space-5)
+ calc(var(--space-5) + env(safe-area-inset-bottom));
+
+ overflow-y: auto;
+
+ overscroll-behavior: contain;
+ }
+
+ /*
+ * Footer handles the safe-area spacing when present,
+ * so the body's extra bottom padding is unnecessary.
+ */
+ .sheet__body:has(+ .sheet__footer) {
+ padding-block-end: var(--space-4);
+ }
+
+ /* =========================================================
+ Footer
+ ========================================================= */
+
+ .sheet__footer {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: flex-end;
+ gap: var(--space-3);
+
+ padding: var(--space-4) var(--space-5)
+ calc(var(--space-4) + env(safe-area-inset-bottom));
+
+ background-color: var(--color-surface-raised);
+
+ border-top: var(--border-width-thin) solid var(--color-border-divider);
+ }
+
+ /* =========================================================
+ Animation
+ ========================================================= */
+
+ @keyframes sheet-enter {
+ from {
+ transform: translateY(100%);
+
+ opacity: 0.7;
+ }
+
+ to {
+ transform: translateY(0);
+
+ opacity: 1;
+ }
+ }
+
+ @keyframes sheet-backdrop-in {
+ from {
+ opacity: 0;
+ }
+
+ to {
+ opacity: 1;
+ }
+ }
+
+ /* =========================================================
+ Wider screens
+ ========================================================= */
+
+ @media (min-width: 48rem) {
+ .sheet {
+ inset-block-end: var(--space-4);
+
+ width: min(calc(100% - (var(--space-6) * 2)), 42rem);
+
+ border-block-end: var(--border-width-thin) solid
+ var(--color-border-subtle);
+
+ border-radius: var(--radius-xl);
+ }
+ }
+
+ /* =========================================================
+ Narrow screens
+ ========================================================= */
+
+ @media (max-width: 30rem) {
+ .sheet__header {
+ padding-inline: var(--space-4);
+ }
+
+ .sheet__body {
+ padding-inline: var(--space-4);
+ }
+
+ .sheet__footer {
+ padding-inline: var(--space-4);
+ }
+ }
+
+ /* =========================================================
+ Reduced motion
+ ========================================================= */
+
+ @media (prefers-reduced-motion: reduce) {
+ .sheet[open],
+ .sheet::backdrop {
+ animation: none;
+ }
+ }
+}
diff --git a/apps/web/src/components/ui/Sheet/Sheet.tsx b/apps/web/src/components/ui/Sheet/Sheet.tsx
new file mode 100644
index 0000000..fb247a8
--- /dev/null
+++ b/apps/web/src/components/ui/Sheet/Sheet.tsx
@@ -0,0 +1,85 @@
+import type { ReactNode } from 'react';
+
+import { CloseIcon } from '../../../icons/actions';
+import IconButton from '../IconButton/IconButton';
+import { useDialogControl } from '../internal/useDialogControl';
+import './Sheet.css';
+
+export type SheetProps = {
+ open: boolean;
+ title: ReactNode;
+ description?: ReactNode;
+ children: ReactNode;
+ footer?: ReactNode;
+ showHandle?: boolean;
+ showCloseButton?: boolean;
+ closeLabel?: string;
+ closeOnBackdrop?: boolean;
+ onClose: () => void;
+};
+
+function Sheet({
+ open,
+ title,
+ description,
+ children,
+ footer,
+ showHandle = true,
+ showCloseButton = true,
+ closeLabel = 'Close sheet',
+ closeOnBackdrop = true,
+ onClose,
+}: SheetProps) {
+ const { dialogRef, titleId, descriptionId, handleCancel } = useDialogControl({
+ open,
+ onClose,
+ closeOnBackdrop,
+ hasDescription: Boolean(description),
+ });
+
+ return (
+
+ {showHandle && (
+
+
+
+ )}
+
+
+
+
+ {title}
+
+
+ {description && (
+
+ {description}
+
+ )}
+
+
+ {showCloseButton && (
+
+ )}
+
+
+ {children}
+
+ {footer && }
+
+ );
+}
+
+export default Sheet;
diff --git a/apps/web/src/components/ui/Toast/Toast.css b/apps/web/src/components/ui/Toast/Toast.css
new file mode 100644
index 0000000..1f0bfc6
--- /dev/null
+++ b/apps/web/src/components/ui/Toast/Toast.css
@@ -0,0 +1,102 @@
+@layer components {
+ .toast {
+ --toast-color: var(--color-feedback-info);
+
+ --toast-surface: var(--color-feedback-info-surface);
+
+ --toast-border: var(--color-feedback-info-border);
+
+ display: flex;
+ align-items: flex-start;
+ gap: var(--space-3);
+
+ width: min(24rem, 100%);
+
+ padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
+
+ color: var(--toast-color);
+ background-color: var(--toast-surface);
+
+ border: var(--border-width-thin) solid var(--toast-border);
+
+ border-radius: var(--radius-lg);
+
+ box-shadow: var(--shadow-lg);
+ }
+
+ .toast--success {
+ --toast-color: var(--color-feedback-success);
+
+ --toast-surface: var(--color-feedback-success-surface);
+
+ --toast-border: var(--color-feedback-success-border);
+ }
+
+ .toast--error {
+ --toast-color: var(--color-feedback-error);
+
+ --toast-surface: var(--color-feedback-error-surface);
+
+ --toast-border: var(--color-feedback-error-border);
+ }
+
+ .toast--warning {
+ --toast-color: var(--color-feedback-warning);
+
+ --toast-surface: var(--color-feedback-warning-surface);
+
+ --toast-border: var(--color-feedback-warning-border);
+ }
+
+ .toast--info {
+ --toast-color: var(--color-feedback-info);
+
+ --toast-surface: var(--color-feedback-info-surface);
+
+ --toast-border: var(--color-feedback-info-border);
+ }
+
+ .toast__icon {
+ display: inline-flex;
+ flex: 0 0 auto;
+
+ margin-block-start: var(--space-1);
+ }
+
+ .toast__icon > svg {
+ width: var(--icon-size-md);
+ height: var(--icon-size-md);
+ }
+
+ .toast__content {
+ display: flex;
+ flex: 1 1 auto;
+ flex-direction: column;
+ gap: var(--space-1);
+
+ min-width: 0;
+
+ padding-block-start: var(--space-1);
+ }
+
+ .toast__title {
+ color: var(--toast-color);
+
+ font-weight: var(--font-weight-semibold);
+
+ line-height: var(--line-height-snug);
+ }
+
+ .toast__message {
+ color: var(--color-text-secondary);
+
+ font-size: var(--font-size-sm);
+ line-height: var(--line-height-normal);
+ }
+
+ @media (max-width: 30rem) {
+ .toast {
+ width: 100%;
+ }
+ }
+}
diff --git a/apps/web/src/components/ui/Toast/Toast.tsx b/apps/web/src/components/ui/Toast/Toast.tsx
new file mode 100644
index 0000000..6517564
--- /dev/null
+++ b/apps/web/src/components/ui/Toast/Toast.tsx
@@ -0,0 +1,66 @@
+import { useEffect, type ReactNode } from 'react';
+
+import { CloseIcon } from '../../../icons/actions';
+import { Icon } from '../Icon/Icon';
+import IconButton from '../IconButton/IconButton';
+import {
+ feedbackIcon,
+ feedbackRole,
+ type FeedbackTone,
+} from '../internal/feedbackTone';
+import './Toast.css';
+
+export type ToastTone = FeedbackTone;
+
+export type ToastProps = {
+ open: boolean;
+ tone?: ToastTone;
+ title?: ReactNode;
+ children: ReactNode;
+ duration?: number | null;
+ onClose: () => void;
+};
+
+function Toast({
+ open,
+ tone = 'info',
+ title,
+ children,
+ duration = 5000,
+ onClose,
+}: ToastProps) {
+ useEffect(() => {
+ if (!open || duration === null) return;
+ const timeout = window.setTimeout(onClose, duration);
+ return () => window.clearTimeout(timeout);
+ }, [open, duration, onClose]);
+
+ if (!open) return null;
+
+ return (
+
+
+
+
+
+
+ {title &&
{title} }
+
{children}
+
+
+
+
+ );
+}
+
+export default Toast;
diff --git a/apps/web/src/components/ui/__tests__/ConfirmationDialog.test.tsx b/apps/web/src/components/ui/__tests__/ConfirmationDialog.test.tsx
new file mode 100644
index 0000000..019a4b2
--- /dev/null
+++ b/apps/web/src/components/ui/__tests__/ConfirmationDialog.test.tsx
@@ -0,0 +1,48 @@
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { describe, expect, it, vi } from 'vitest';
+
+import ConfirmationDialog from '../ConfirmationDialog/ConfirmationDialog';
+
+describe('ConfirmationDialog', () => {
+ it('calls onConfirm from the confirm action', async () => {
+ const user = userEvent.setup();
+ const onConfirm = vi.fn();
+
+ render(
+
undefined}
+ tone="error"
+ >
+ This action cannot be undone.
+ ,
+ );
+
+ await user.click(screen.getByRole('button', { name: 'Delete' }));
+
+ expect(onConfirm).toHaveBeenCalledTimes(1);
+ });
+
+ it('calls onCancel from the cancel action', async () => {
+ const user = userEvent.setup();
+ const onCancel = vi.fn();
+
+ render(
+
undefined}
+ onCancel={onCancel}
+ tone="error"
+ />,
+ );
+
+ await user.click(screen.getByRole('button', { name: 'Cancel' }));
+
+ expect(onCancel).toHaveBeenCalledTimes(1);
+ });
+});
diff --git a/apps/web/src/components/ui/__tests__/Dialog.test.tsx b/apps/web/src/components/ui/__tests__/Dialog.test.tsx
new file mode 100644
index 0000000..9109381
--- /dev/null
+++ b/apps/web/src/components/ui/__tests__/Dialog.test.tsx
@@ -0,0 +1,96 @@
+import { useState } from 'react';
+import { fireEvent, render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { describe, expect, it, vi } from 'vitest';
+
+import Dialog from '../Dialog/Dialog';
+
+describe('Dialog', () => {
+ it('has an accessible title and description and closes from its close button', async () => {
+ const user = userEvent.setup();
+ const onClose = vi.fn();
+
+ render(
+
+ Dialog body
+ ,
+ );
+
+ const dialog = screen.getByRole('dialog', {
+ name: 'Recipe information',
+ });
+ const description = screen.getByText('Details about this recipe');
+
+ expect(dialog.hasAttribute('open')).toBe(true);
+ expect(dialog.getAttribute('aria-describedby')).toBe(description.id);
+
+ await user.click(screen.getByRole('button', { name: 'Close dialog' }));
+
+ expect(onClose).toHaveBeenCalledTimes(1);
+ });
+
+ it('requests close from the native cancel event used by Escape', () => {
+ const onClose = vi.fn();
+
+ render(
+
+ Dialog body
+ ,
+ );
+
+ const dialog = screen.getByRole('dialog');
+
+ fireEvent(
+ dialog,
+ new Event('cancel', {
+ bubbles: false,
+ cancelable: true,
+ }),
+ );
+
+ expect(onClose).toHaveBeenCalledTimes(1);
+ });
+
+ it('restores focus to the trigger after the dialog closes', async () => {
+ const user = userEvent.setup();
+
+ function DialogHarness() {
+ const [open, setOpen] = useState(false);
+
+ return (
+ <>
+ setOpen(true)}>
+ Open details
+
+
+ setOpen(false)}
+ >
+ Dialog body
+
+ >
+ );
+ }
+
+ render( );
+
+ const trigger = screen.getByRole('button', {
+ name: 'Open details',
+ });
+
+ await user.click(trigger);
+ await user.click(screen.getByRole('button', { name: 'Close dialog' }));
+ await new Promise((resolve) =>
+ requestAnimationFrame(() => resolve(undefined)),
+ );
+
+ expect(document.activeElement).toBe(trigger);
+ });
+});
diff --git a/apps/web/src/components/ui/__tests__/Sheet.test.tsx b/apps/web/src/components/ui/__tests__/Sheet.test.tsx
new file mode 100644
index 0000000..80350ef
--- /dev/null
+++ b/apps/web/src/components/ui/__tests__/Sheet.test.tsx
@@ -0,0 +1,54 @@
+import { useState } from 'react';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { describe, expect, it } from 'vitest';
+
+import Sheet from '../Sheet/Sheet';
+
+describe('Sheet', () => {
+ it('opens with an accessible title and restores focus after closing', async () => {
+ const user = userEvent.setup();
+
+ function SheetHarness() {
+ const [open, setOpen] = useState(false);
+
+ return (
+ <>
+ setOpen(true)}>
+ Open filters
+
+
+ setOpen(false)}
+ >
+ Filter controls
+
+ >
+ );
+ }
+
+ render( );
+
+ const trigger = screen.getByRole('button', {
+ name: 'Open filters',
+ });
+
+ await user.click(trigger);
+
+ const sheet = screen.getByRole('dialog', {
+ name: 'Recipe filters',
+ });
+
+ expect(sheet.hasAttribute('open')).toBe(true);
+
+ await user.click(screen.getByRole('button', { name: 'Close sheet' }));
+ await new Promise((resolve) =>
+ requestAnimationFrame(() => resolve(undefined)),
+ );
+
+ expect(document.activeElement).toBe(trigger);
+ });
+});
diff --git a/apps/web/src/components/ui/internal/feedbackTone.ts b/apps/web/src/components/ui/internal/feedbackTone.ts
new file mode 100644
index 0000000..370ae97
--- /dev/null
+++ b/apps/web/src/components/ui/internal/feedbackTone.ts
@@ -0,0 +1,25 @@
+import type { ComponentType } from 'react';
+import {
+ AlertTriangleIcon,
+ ErrorIcon,
+ InfoIcon,
+ SuccessIcon,
+} from '../../../icons/status';
+import type { IconProps as SvgIconProps } from '../../../icons/types';
+
+export type FeedbackTone = 'success' | 'error' | 'warning' | 'info';
+
+const FEEDBACK_ICONS: Record> = {
+ success: SuccessIcon,
+ error: ErrorIcon,
+ warning: AlertTriangleIcon,
+ info: InfoIcon,
+};
+
+export function feedbackIcon(tone: FeedbackTone) {
+ return FEEDBACK_ICONS[tone];
+}
+
+export function feedbackRole(tone: FeedbackTone): 'alert' | 'status' {
+ return tone === 'error' ? 'alert' : 'status';
+}
diff --git a/apps/web/src/components/ui/internal/useDialogControl.ts b/apps/web/src/components/ui/internal/useDialogControl.ts
new file mode 100644
index 0000000..01d50b1
--- /dev/null
+++ b/apps/web/src/components/ui/internal/useDialogControl.ts
@@ -0,0 +1,85 @@
+import { useEffect, useId, useRef, type SyntheticEvent } from 'react';
+
+type UseDialogControlOptions = {
+ open: boolean;
+ onClose: () => void;
+ closeOnBackdrop?: boolean;
+ hasDescription?: boolean;
+};
+
+/** Shared native lifecycle, IDs, backdrop handling, and focus restoration. */
+export function useDialogControl({
+ open,
+ onClose,
+ closeOnBackdrop = true,
+ hasDescription = false,
+}: UseDialogControlOptions) {
+ const dialogRef = useRef(null);
+ const previousFocusRef = useRef(null);
+
+ const generatedId = useId();
+ const titleId = `${generatedId}-title`;
+ const descriptionId = hasDescription
+ ? `${generatedId}-description`
+ : undefined;
+
+ useEffect(() => {
+ const dialog = dialogRef.current;
+
+ if (!dialog) {
+ return;
+ }
+
+ if (open && !dialog.open) {
+ const active = document.activeElement;
+
+ previousFocusRef.current = active instanceof HTMLElement ? active : null;
+
+ dialog.showModal();
+ return;
+ }
+
+ if (!open && dialog.open) {
+ dialog.close();
+
+ const previous = previousFocusRef.current;
+ previousFocusRef.current = null;
+
+ window.requestAnimationFrame(() => {
+ previous?.focus();
+ });
+ }
+ }, [open]);
+
+ useEffect(() => {
+ const dialog = dialogRef.current;
+
+ if (!dialog || !closeOnBackdrop) {
+ return;
+ }
+
+ const handleBackdropMouseDown = (event: MouseEvent) => {
+ if (event.target === dialog) {
+ onClose();
+ }
+ };
+
+ dialog.addEventListener('mousedown', handleBackdropMouseDown);
+
+ return () => {
+ dialog.removeEventListener('mousedown', handleBackdropMouseDown);
+ };
+ }, [closeOnBackdrop, onClose]);
+
+ const handleCancel = (event: SyntheticEvent) => {
+ event.preventDefault();
+ onClose();
+ };
+
+ return {
+ dialogRef,
+ titleId,
+ descriptionId,
+ handleCancel,
+ };
+}
diff --git a/apps/web/src/components/ui/showcase/ConfirmationDialogShowcase.tsx b/apps/web/src/components/ui/showcase/ConfirmationDialogShowcase.tsx
new file mode 100644
index 0000000..c1c7f24
--- /dev/null
+++ b/apps/web/src/components/ui/showcase/ConfirmationDialogShowcase.tsx
@@ -0,0 +1,121 @@
+import { useState } from 'react';
+
+import Button from '../Button/Button';
+import ConfirmationDialog from '../ConfirmationDialog/ConfirmationDialog';
+import FeedbackMessage from '../FeedbackMessage/FeedbackMessage';
+import { surfaceStyle } from './showcaseStyles';
+
+type OpenDialog = 'publish' | 'warning' | 'delete' | null;
+
+export default function ConfirmationDialogShowcase() {
+ const [openDialog, setOpenDialog] = useState(null);
+
+ const [message, setMessage] = useState(null);
+
+ return (
+
+
+
+
+
+ Examples
+
+
+
+ {
+ setMessage(null);
+ setOpenDialog('publish');
+ }}
+ >
+ Publish Recipe
+
+
+ {
+ setMessage(null);
+ setOpenDialog('warning');
+ }}
+ >
+ Replace Draft
+
+
+ {
+ setMessage(null);
+ setOpenDialog('delete');
+ }}
+ >
+ Delete Recipe
+
+
+
+ {message && (
+
{message}
+ )}
+
+
+
+
setOpenDialog(null)}
+ onConfirm={() => {
+ setOpenDialog(null);
+ setMessage('Recipe published successfully.');
+ }}
+ >
+ You can still edit the recipe after it has been published.
+
+
+
setOpenDialog(null)}
+ onConfirm={() => {
+ setOpenDialog(null);
+ setMessage('Draft replaced successfully.');
+ }}
+ >
+ Any unsaved content in the current draft will be lost.
+
+
+
setOpenDialog(null)}
+ onConfirm={() => {
+ setOpenDialog(null);
+ setMessage('Recipe deleted successfully.');
+ }}
+ >
+ This action cannot be undone.
+
+
+
+ );
+}
diff --git a/apps/web/src/components/ui/showcase/DialogShowcase.tsx b/apps/web/src/components/ui/showcase/DialogShowcase.tsx
new file mode 100644
index 0000000..583a59e
--- /dev/null
+++ b/apps/web/src/components/ui/showcase/DialogShowcase.tsx
@@ -0,0 +1,126 @@
+import { useState } from 'react';
+
+import Button from '../Button/Button';
+import Dialog, { type DialogTone } from '../Dialog/Dialog';
+import { ChefIcon } from '../../../icons/recipe';
+import {
+ AlertTriangleIcon,
+ ErrorIcon,
+ InfoIcon,
+ SuccessIcon,
+} from '../../../icons/status';
+import { surfaceStyle } from './showcaseStyles';
+
+const examples: {
+ tone: DialogTone;
+ label: string;
+}[] = [
+ {
+ tone: 'primary',
+ label: 'Primary',
+ },
+ {
+ tone: 'brand',
+ label: 'Brand',
+ },
+ {
+ tone: 'info',
+ label: 'Info',
+ },
+ {
+ tone: 'warning',
+ label: 'Warning',
+ },
+ {
+ tone: 'success',
+ label: 'Success',
+ },
+ {
+ tone: 'error',
+ label: 'Error',
+ },
+];
+
+function iconForTone(tone: DialogTone) {
+ switch (tone) {
+ case 'primary':
+ case 'brand':
+ return ChefIcon;
+ case 'info':
+ return InfoIcon;
+ case 'warning':
+ return AlertTriangleIcon;
+ case 'success':
+ return SuccessIcon;
+ case 'error':
+ return ErrorIcon;
+ }
+}
+
+export default function DialogShowcase() {
+ const [openTone, setOpenTone] = useState(null);
+
+ return (
+
+
+
+
+
+ Tones
+
+
+ The buttons preview the visual tone used by each dialog.
+
+
+
+ {examples.map((example) => (
+ setOpenTone(example.tone)}
+ >
+ {example.label}
+
+ ))}
+
+
+
+ {examples.map((example) => (
+
setOpenTone(null)}
+ footer={ setOpenTone(null)}>Got It }
+ >
+
+
+ This dialog keeps the main surface neutral while using its icon
+ treatment to communicate visual emphasis.
+
+
+
+ That keeps the dialog readable without turning the entire modal
+ into a large colored surface.
+
+
+
+ ))}
+
+
+ );
+}
diff --git a/apps/web/src/components/ui/showcase/EmptyStateShowcase.tsx b/apps/web/src/components/ui/showcase/EmptyStateShowcase.tsx
new file mode 100644
index 0000000..fbb9170
--- /dev/null
+++ b/apps/web/src/components/ui/showcase/EmptyStateShowcase.tsx
@@ -0,0 +1,96 @@
+import Button from '../Button/Button';
+import EmptyState from '../EmptyState/EmptyState';
+import { HeartIcon } from '../../../icons/actions';
+import { CookbookIcon, SearchIcon } from '../../../icons/navigation';
+import { surfaceStyle } from './showcaseStyles';
+
+export default function EmptyStateShowcase() {
+ return (
+
+
+
+
+
+ Cookbook
+
+ Explore Recipes}
+ />
+
+
+
+ No Search Results
+
+
+ Clear Filters
+
+ Browse All Recipes
+ >
+ }
+ />
+
+
+
+ Plain Variant
+
+
+ Find Recipes}
+ />
+
+
+
+
+ Compact
+
+
+
+ Clear Filter
+
+ }
+ />
+
+
+
+
+
+
+ );
+}
diff --git a/apps/web/src/components/ui/showcase/FeedbackMessageShowcase.tsx b/apps/web/src/components/ui/showcase/FeedbackMessageShowcase.tsx
new file mode 100644
index 0000000..9f4f945
--- /dev/null
+++ b/apps/web/src/components/ui/showcase/FeedbackMessageShowcase.tsx
@@ -0,0 +1,112 @@
+import FeedbackMessage from '../FeedbackMessage/FeedbackMessage';
+import { surfaceStyle } from './showcaseStyles';
+
+export default function FeedbackMessageShowcase() {
+ return (
+
+
+
+ FeedbackMessage Showcase
+
+
+ Inline feedback for success, error, warning, and informational
+ states.
+
+
+
+
+ All Tones
+
+
+
+ Spaghetti Carbonara was added to your cookbook.
+
+
+
+ Check the required fields and try again.
+
+
+
+ Leaving this page will discard your current changes.
+
+
+
+ Public recipes can be discovered by other users.
+
+
+
+
+
+ Without Titles
+
+
+
+ Your changes were saved successfully.
+
+
+
+ Enter a valid email address.
+
+
+
+ This recipe has not been published yet.
+
+
+
+ Cooking times are approximate.
+
+
+
+
+
+ Form Context
+
+
+
Create Account
+
+
+ Correct the highlighted fields before trying again.
+
+
+
+
+
+ Narrow Layout
+
+
+
+ Preparation and resting time may not be included.
+
+
+
+
+
+ );
+}
diff --git a/apps/web/src/components/ui/showcase/SheetShowcase.tsx b/apps/web/src/components/ui/showcase/SheetShowcase.tsx
new file mode 100644
index 0000000..ef0182f
--- /dev/null
+++ b/apps/web/src/components/ui/showcase/SheetShowcase.tsx
@@ -0,0 +1,293 @@
+import { useEffect, useMemo, useRef, useState } from 'react';
+
+import { CameraIcon, DeleteIcon, ImageIcon } from '../../../icons/actions';
+import Button from '../Button/Button';
+import FeedbackMessage from '../FeedbackMessage/FeedbackMessage';
+import Menu, { type MenuEntry } from '../Menu/Menu';
+import Sheet from '../Sheet/Sheet';
+import { surfaceStyle } from './showcaseStyles';
+
+const searchStyle = {
+ width: '100%',
+ minHeight: 'var(--control-height-md)',
+
+ paddingInline: 'var(--space-3)',
+
+ color: 'var(--color-text-primary)',
+
+ backgroundColor: 'var(--color-surface)',
+
+ font: 'inherit',
+
+ border: 'var(--border-width-thin) solid var(--color-border-input)',
+
+ borderRadius: 'var(--radius-md)',
+};
+
+const categoryRowStyle = {
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ gap: 'var(--space-3)',
+
+ minHeight: 'var(--target-size-min)',
+
+ padding: 'var(--space-2) var(--space-3)',
+
+ borderRadius: 'var(--radius-md)',
+
+ cursor: 'pointer',
+};
+
+const categories = [
+ 'Breakfast',
+ 'Lunch',
+ 'Dinner',
+ 'Appetizer',
+ 'Dessert',
+ 'Side Dish',
+ 'Snack',
+ 'Soup',
+ 'Salad',
+];
+
+export default function SheetShowcase() {
+ const [categoryOpen, setCategoryOpen] = useState(false);
+
+ const [photoOpen, setPhotoOpen] = useState(false);
+
+ const [selectedCategory, setSelectedCategory] = useState('Dinner');
+
+ const [search, setSearch] = useState('');
+
+ const [message, setMessage] = useState(null);
+
+ const searchInputRef = useRef(null);
+
+ useEffect(() => {
+ if (!categoryOpen) {
+ return;
+ }
+
+ const frame = window.requestAnimationFrame(() => {
+ searchInputRef.current?.focus();
+ });
+
+ return () => {
+ window.cancelAnimationFrame(frame);
+ };
+ }, [categoryOpen]);
+
+ const filteredCategories = useMemo(() => {
+ const query = search.trim().toLowerCase();
+
+ if (!query) {
+ return categories;
+ }
+
+ return categories.filter((category) =>
+ category.toLowerCase().includes(query),
+ );
+ }, [search]);
+
+ const photoActions: MenuEntry[] = [
+ {
+ id: 'camera',
+ label: 'Take Photo',
+ icon: CameraIcon,
+ onSelect: () => {
+ setPhotoOpen(false);
+
+ setMessage('Take Photo selected.');
+ },
+ },
+ {
+ id: 'library',
+ label: 'Choose from Library',
+ icon: ImageIcon,
+ onSelect: () => {
+ setPhotoOpen(false);
+
+ setMessage('Choose from Library selected.');
+ },
+ },
+ {
+ id: 'separator',
+ type: 'separator',
+ },
+ {
+ id: 'remove',
+ label: 'Remove Current Photo',
+ icon: DeleteIcon,
+ tone: 'destructive',
+ onSelect: () => {
+ setPhotoOpen(false);
+
+ setMessage('Remove Current Photo selected.');
+ },
+ },
+ ];
+
+ return (
+
+
+
+
+
+ Recipe Form Examples
+
+
+
+ setCategoryOpen(true)}>
+ Select Category
+
+
+ setPhotoOpen(true)}>
+ Add Recipe Photo
+
+
+
+
+ Selected category: {selectedCategory}
+
+
+ {message && (
+
{message}
+ )}
+
+
+
+ {/* Category Sheet */}
+
+
setCategoryOpen(false)}
+ footer={
+ <>
+ setCategoryOpen(false)}>
+ Cancel
+
+
+ setCategoryOpen(false)}>Done
+ >
+ }
+ >
+
+
setSearch(event.target.value)}
+ />
+
+
+ Recipe category
+
+
+ {filteredCategories.map((category) => {
+ const selected = category === selectedCategory;
+
+ return (
+
+
+ {category}
+
+
+ setSelectedCategory(category)}
+ />
+
+ );
+ })}
+
+ {filteredCategories.length === 0 && (
+
+ No categories match your search.
+
+ )}
+
+
+
+
+
+ {/* Photo Sheet */}
+
+
setPhotoOpen(false)}
+ footer={
+ setPhotoOpen(false)}>
+ Cancel
+
+ }
+ >
+
+
+
+
+ Behavior
+
+
+
+ The sheet can be closed using its close button, the Escape key,
+ the backdrop, or an explicit action.
+
+
+
+ The body scrolls independently when its content becomes taller
+ than the available viewport.
+
+
+
+
+
+ );
+}
diff --git a/apps/web/src/components/ui/showcase/ToastShowcase.tsx b/apps/web/src/components/ui/showcase/ToastShowcase.tsx
new file mode 100644
index 0000000..a7e47ec
--- /dev/null
+++ b/apps/web/src/components/ui/showcase/ToastShowcase.tsx
@@ -0,0 +1,126 @@
+import { useCallback, useState } from 'react';
+
+import Button from '../Button/Button';
+import Toast, { type ToastTone } from '../Toast/Toast';
+import { surfaceStyle } from './showcaseStyles';
+
+type OpenToast = ToastTone | null;
+
+export default function ToastShowcase() {
+ const [openToast, setOpenToast] = useState(null);
+
+ const closeToast = useCallback(() => {
+ setOpenToast(null);
+ }, []);
+
+ return (
+
+
+
+
+
+ Examples
+
+
+ setOpenToast('success')}>
+ Success Toast
+
+
+ setOpenToast('info')}>
+ Info Toast
+
+
+ setOpenToast('warning')}>
+ Warning Toast
+
+
+ setOpenToast('error')}>
+ Error Toast
+
+
+
+
+
+ Preview
+
+
+ {openToast === null && (
+
Open a toast above to preview it.
+ )}
+
+
+ Spaghetti Carbonara was saved to your cookbook.
+
+
+
+ Your latest changes are now visible.
+
+
+
+ Your changes are saved, but the recipe is still private.
+
+
+
+ Try saving the recipe again.
+
+
+
+
+
+ Persistent
+
+
+ {}}
+ >
+ Setting duration to null prevents automatic dismissal.
+
+
+
+
+
+ );
+}
diff --git a/apps/web/src/components/ui/showcase/UiShowcaseCatalog.tsx b/apps/web/src/components/ui/showcase/UiShowcaseCatalog.tsx
index e36e15c..e55dd81 100644
--- a/apps/web/src/components/ui/showcase/UiShowcaseCatalog.tsx
+++ b/apps/web/src/components/ui/showcase/UiShowcaseCatalog.tsx
@@ -2,7 +2,11 @@ import AvatarShowcase from './AvatarShowcase';
import BreadcrumbsShowcase from './BreadcrumbsShowcase';
import ButtonShowcase from './ButtonShowcase';
import CheckboxShowcase from './CheckboxShowcase';
+import ConfirmationDialogShowcase from './ConfirmationDialogShowcase';
+import DialogShowcase from './DialogShowcase';
import DropdownMenuShowcase from './DropdownMenuShowcase';
+import EmptyStateShowcase from './EmptyStateShowcase';
+import FeedbackMessageShowcase from './FeedbackMessageShowcase';
import FieldShowcase from './FieldShowcase';
import FilterChipShowcase from './FilterChipShowcase';
import IconBadgeShowcase from './IconBadgeShowcase';
@@ -12,17 +16,21 @@ import LoadingIndicatorShowcase from './LoadingIndicatorShowcase';
import PaginationShowcase from './PaginationShowcase';
import RadioShowcase from './RadioShowcase';
import SelectShowcase from './SelectShowcase';
+import SheetShowcase from './SheetShowcase';
import TabsShowcase from './TabsShowcase';
import TagShowcase from './TagShowcase';
import TextareaShowcase from './TextareaShowcase';
+import ToastShowcase from './ToastShowcase';
import ToggleSwitchShowcase from './ToggleSwitchShowcase';
import TooltipShowcase from './TooltipShowcase';
-// Intentionally render every available showcase in one scrollable catalog.
+// Intentionally render every showcase in one scrollable catalog.
// This page doubles as a quick visual/responsive review surface.
export default function UiShowcaseCatalog() {
return (
+
+
@@ -31,16 +39,26 @@ export default function UiShowcaseCatalog() {
+
+
+
+
+
+
+
+
+
+