================
LIBRARY RULES
================
- Use UZH DF design-system components whenever they are available for frontend tasks
- Use theme-based styling with Tailwind CSS
================
CODE SNIPPETS
================
TITLE: Default Command Palette Example with Suggestions and Settings (TSX)
DESCRIPTION: A practical example of the `Command` component demonstrating a default setup with grouped suggestions and settings. It includes an input, empty state, and items with icons and keyboard shortcuts, showcasing common usage patterns.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Command.stories.mdx#_snippet_2
LANGUAGE: tsx
CODE:
```
export const Default = () => {
return (
No results found.CalendarSearch EmojiCalculatorProfile⌘PBilling⌘BSettings⌘S
)
}
```
--------------------------------
TITLE: Default Pagination Component Example
DESCRIPTION: This example demonstrates the default rendering of the Pagination component, showcasing a standard setup with previous/next buttons, numbered page links, and an ellipsis indicator for skipped pages.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Pagination.stories.mdx#_snippet_2
LANGUAGE: tsx
CODE:
```
export const Default = () => {
return (
1
2
3
)
}
```
--------------------------------
TITLE: Basic Tabs Usage
DESCRIPTION: Example demonstrating the basic setup of the Tabs component with three distinct tab sections.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Tabs.stories.mdx#_snippet_2
LANGUAGE: tsx
CODE:
```
import { useState } from 'react'
import { TabContent, Tabs } from './Tabs'
function ExampleTabs() {
return (
Overview Content
Summary information goes here.
Detailed Information
More specific details about the item.
Settings Panel
Configure options here.
)
}
```
--------------------------------
TITLE: Basic Modal Example
DESCRIPTION: A simple example of a Modal component with only the essential props for opening and closing.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Modal.stories.mdx#_snippet_12
LANGUAGE: jsx
CODE:
```
export const Basic = () => {
const [isOpen, setIsOpen] = useState(false)
return (
setIsOpen(true)}>Open Modal}
onClose={() => setIsOpen(false)}
>
Consectetur enim adipisicing do culpa. Laborum laboris labore velit
incididunt est do duis in cupidatat proident. Veniam quis ex dolore
pariatur eu. Quis adipisicing aliqua et Lorem minim. Nostrud anim duis
commodo nostrud deserunt adipisicing dolor officia amet non tempor tempor
laboris. Nisi esse voluptate non enim aute nisi nostrud eiusmod laboris.
)
}
```
--------------------------------
TITLE: Navigation Handler Examples
DESCRIPTION: Provides examples of different navigation handler functions for various scenarios like form wizards, quiz reviews, and linear process tracking.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/StepProgress.stories.mdx#_snippet_11
LANGUAGE: javascript
CODE:
```
// Form wizard navigation
const handleStepClick = (step, item) => {
if (step <= completedSteps) {
setCurrentStep(step)
} else {
// Prevent navigation to incomplete steps
showWarning('Please complete current step first')
}
}
// Quiz review navigation
const handleQuizReview = (step, item) => {
setCurrentStep(step)
setReviewMode(true)
loadQuestionData(item.id)
}
// Linear process with status tracking
const handleProcessStep = (step, item) => {
updateStepStatus(currentStep, 'completed')
setCurrentStep(step)
logStepNavigation(step, item)
}
```
--------------------------------
TITLE: Account Recovery PIN Example
DESCRIPTION: Provides an example of using FormikPinField for account recovery, including a descriptive header and tooltip.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/forms/FormikPinField.stories.mdx#_snippet_5
LANGUAGE: tsx
CODE:
```
import { Form, Formik } from 'formik';
import FormikPinField from './FormikPinField';
// Account recovery PIN
```
--------------------------------
TITLE: Basic AlertDialog Usage Example
DESCRIPTION: A basic example demonstrating the implementation of an AlertDialog component. It shows how to set up a trigger button, define the dialog's header, title, description, and footer with cancel and continue actions.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/AlertDialog.stories.mdx#_snippet_2
LANGUAGE: tsx
CODE:
```
export const Default = () => {
return (
Are you absolutely sure?
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
CancelContinue
)
}
```
--------------------------------
TITLE: Simple Table Example
DESCRIPTION: A basic example of rendering a Table component with predefined columns and data.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Table.stories.mdx#_snippet_6
LANGUAGE: jsx
CODE:
```
import React from 'react';
import { Table } from './Table'; // Assuming Table component is in './Table'
import { UserNotification } from './UserNotification'; // Assuming UserNotification component is in './UserNotification'
const data = [
{ count: 10, answer: 'Yes', username: 'user1' },
{ count: 5, answer: 'No', username: 'user2' },
{ count: 15, answer: 'Maybe', username: 'user3' },
];
export const SimpleTable = () => (
);
```
--------------------------------
TITLE: Default ShadcnProgress Example
DESCRIPTION: A basic example of the ShadcnProgress component, demonstrating an animated progress bar that transitions from 13% to 66%.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/ShadcnProgress.stories.mdx#_snippet_1
LANGUAGE: tsx
CODE:
```
import { useState, useEffect } from 'react'
import { ShadcnProgress } from './ShadcnProgress'
export const Default = () => {
const [progress, setProgress] = useState(13)
useEffect(() => {
const timer = setTimeout(() => setProgress(66), 500)
return () => clearTimeout(timer)
}, [])
return
}
```
--------------------------------
TITLE: Basic Step Progress Example
DESCRIPTION: Demonstrates the basic usage of the StepProgress component with numeric steps and click navigation.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/StepProgress.stories.mdx#_snippet_1
LANGUAGE: javascript
CODE:
```
import React, { useState } from 'react';
import StepProgress from './StepProgress';
function App() {
const [currentStep, setCurrentStep] = useState(0);
return (
Multi-Step Process
setCurrentStep(step)}
/>
Current Step: {currentStep + 1}
);
}
export default App;
```
--------------------------------
TITLE: Default Dropdown Example
DESCRIPTION: A basic example of the Dropdown component rendering simple clickable menu items.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Dropdown.stories.mdx#_snippet_8
LANGUAGE: jsx
CODE:
```
export const Default = () => {
return (
If items are given to the dropdown menu component, they are rendered as
single elements. Any data passed via the groups attribute is ignored and not
displayed.
)
}
```
--------------------------------
TITLE: Default ShadcnProgress Component Example
DESCRIPTION: A basic example demonstrating the `ShadcnProgress` component with a simple animation that updates its value from 13% to 66% after a short delay. This showcases a common pattern for displaying initial loading states or partial progress.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/ShadcnProgress.stories.mdx#_snippet_2
LANGUAGE: tsx
CODE:
```
import { useState, useEffect } from 'react'
import { ShadcnProgress } from './ShadcnProgress'
export const Default = () => {
const [progress, setProgress] = useState(13)
useEffect(() => {
const timer = setTimeout(() => setProgress(66), 500)
return () => clearTimeout(timer)
}, [])
return
}
```
--------------------------------
TITLE: Default Collapsible Example
DESCRIPTION: A simple example demonstrating the default usage of the Collapsible component with basic static and closed content.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Collapsible.stories.mdx#_snippet_6
LANGUAGE: tsx
CODE:
```
import React, { useState } from 'react';
// Assuming Collapsible component is imported
// import Collapsible from 'your-library';
export const Default = () => {
const [open, setOpen] = useState(false)
return (
{
setOpen(!open)
}}
staticContent="Static content"
closedContent="Closed content"
>
Dynamic content
)
}
```
--------------------------------
TITLE: ATM-Style PIN Entry Example
DESCRIPTION: Shows an example of an ATM-style PIN entry using FormikPinField with custom styling and validation.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/forms/FormikPinField.stories.mdx#_snippet_3
LANGUAGE: tsx
CODE:
```
import { Form, Formik } from 'formik';
import FormikPinField from './FormikPinField';
// ATM-style PIN entry
```
--------------------------------
TITLE: Card Component Usage Examples
DESCRIPTION: Demonstrates various ways to use the Card component, from basic content display to more complex structures like product cards and login forms. Includes examples with CardHeader, CardContent, and CardFooter.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Card.stories.mdx#_snippet_0
LANGUAGE: tsx
CODE:
```
import { Button } from './Button'
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from './ui/card'
// Basic content card
Card TitleCard description or subtitle
Main content goes here...
// Simple card without header/footer
Simple Content
Just content with consistent padding.
// Product card example
Product Name$99.99
```
--------------------------------
TITLE: ShadcnMenubar Component Example
DESCRIPTION: This code snippet demonstrates the full implementation of the ShadcnMenubar component, showcasing various menu items, sub-menus, checkboxes, radio groups, and shortcuts. It serves as a practical example for integrating the component into an application.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/ShadcnMenubar.stories.mdx#_snippet_4
LANGUAGE: jsx
CODE:
```
export const Default = () => {
return (
File
New Tab ⌘T
New Window ⌘NNew Incognito WindowShareEmail linkMessagesNotes
Print... ⌘PEdit
Undo ⌘Z
Redo ⇧⌘ZFindSearch the webFind...Find NextFind PreviousCutCopyPasteView
Always Show Bookmarks Bar
Always Show Full URLs
Reload ⌘R
Force Reload ⇧⌘RToggle FullscreenHide SidebarProfilesAndy
Benoit
LuisEdit...Add Profile...
)
}
```
--------------------------------
TITLE: FormikColorPicker - Default Example
DESCRIPTION: A basic example of using the FormikColorPicker with a single color field and a submit button.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/forms/FormikColorPicker.stories.mdx#_snippet_6
LANGUAGE: jsx
CODE:
```
import {
Formik
} from 'formik';
import {
FormikColorPicker
} from './FormikColorPicker'; // Assuming path to component
import {
Form
} from './Form'; // Assuming Form component exists
export const Default = () => (
{
alert(
`Form submitted with color: ${values.color}. The form will be reset.`
)
resetForm()
}}
>
{({ values }) => {
return (
)
}}
)
```
--------------------------------
TITLE: Default NavigationMenu Example
DESCRIPTION: A basic implementation of the NavigationMenu component, showcasing a primary navigation item 'Home' with a dropdown content area. This example demonstrates the core structure for creating navigation hierarchies.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/NavigationMenu.stories.mdx#_snippet_4
LANGUAGE: jsx
CODE:
```
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
} from "@/components/ui/navigation-menu"
export const Default = () => {
return (
Home
Re-usable components built using Radix UI and Tailwind
CSS.
>
<>
Installation
How to install dependencies and structure your app.
>
<>
Typography
Styles for headings, paragraphs, lists...etc
>
Components
{[ { title: 'Alert Dialog', /* ... */ } ]}
)
}
```
--------------------------------
TITLE: Basic Workflow Example
DESCRIPTION: Demonstrates the basic usage of the Workflow component with clickable steps and active state management using React's useState hook.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Workflow.stories.mdx#_snippet_1
LANGUAGE: javascript
CODE:
```
import { useState } from 'react'
import Workflow from './Workflow'
import {
workflowItemsDescription,
workflowTooltipItems,
workflowItems,
} from './values'
export function Default() {
const [activeIx, setActiveIx] = useState(0)
return (
The workflow component always grows to 100% width of the parent
container and splits the available space evenly between the number of
passed items. If a description is passed, the height of the component
adapts accordingly. Limited custom styling is available. The items can
contain custom data, which is passed back to the onClick handler.
setActiveIx(ix)}
activeIx={activeIx}
/>
)
}
```
--------------------------------
TITLE: Link Component Example
DESCRIPTION: Demonstrates the usage of a 'link' component, including its label, click handler, optional badge, and associated CSS classes.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Navigation.stories.mdx#_snippet_17
LANGUAGE: javascript
CODE:
```
{
key: 'dropdown-menubar-item1',
type: 'link',
label: 'Item 1',
onClick: () => alert('Item 1 clicked'),
notification: true,
}
```
LANGUAGE: javascript
CODE:
```
{
key: 'dropdown-menubar-item2',
type: 'link',
label: 'Item 2',
onClick: () => alert('Item 2 clicked'),
badge: 'Coming Soon',
className: { badge: 'bg-orange-500 hover:bg-orange-600' },
}
```
LANGUAGE: javascript
CODE:
```
{
key: 'dropdown-menubar-item3',
type: 'link',
label: 'Item 3',
onClick: () => alert('Item 3 clicked'),
}
```
--------------------------------
TITLE: Basic Drawer Usage Example
DESCRIPTION: Demonstrates the basic implementation of the Drawer component, including a trigger button and content with header, description, and footer actions.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Drawer.stories.mdx#_snippet_1
LANGUAGE: tsx
CODE:
```
SettingsAdjust your preferences
Notifications
Dark Mode
```
--------------------------------
TITLE: Skeleton Component Usage Examples
DESCRIPTION: Demonstrates various ways to use the Skeleton component for different content structures, including text lines, profile cards, general cards, and table rows. Each example shows how to apply CSS classes to define the shape, size, and animation of the placeholders.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Skeleton.stories.mdx#_snippet_0
LANGUAGE: tsx
CODE:
```
// Text line skeletons
// Profile card skeleton
// Card skeleton
// Table row skeletons
{Array.from({ length: 5 }).map((_, i) => (
))}
```
--------------------------------
TITLE: FullScreen Modal Example
DESCRIPTION: Illustrates how to render the Modal component in full-screen mode.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Modal.stories.mdx#_snippet_3
LANGUAGE: react
CODE:
```
import React, { useState } from 'react';
import Modal from './Modal';
function App() {
const [isOpen, setIsOpen] = useState(false);
return (
);
}
export default App;
```
--------------------------------
TITLE: Basic Sidebar Usage Example
DESCRIPTION: Demonstrates a basic implementation of the Sidebar component with header, grouped navigation, and main content.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Sidebar.stories.mdx#_snippet_1
LANGUAGE: tsx
CODE:
```
```
--------------------------------
TITLE: Default Countdown Example
DESCRIPTION: A basic example demonstrating how to use the Countdown component with an expiration time.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Countdown.stories.mdx#_snippet_1
LANGUAGE: jsx
CODE:
```
export const Default = () => {
const time = new Date()
time.setSeconds(time.getSeconds() + 40)
return
}
```
--------------------------------
TITLE: Default RadioGroup Story Example
DESCRIPTION: A simple example demonstrating the `RadioGroup` component with three predefined options ('default', 'comfortable', 'compact') and associated labels. This snippet showcases the basic rendering and functionality of the component in a typical usage scenario.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/RadioGroup.stories.mdx#_snippet_2
LANGUAGE: tsx
CODE:
```
export const Default = () => {
return (
Default
Comfortable
Compact
)
}
```
--------------------------------
TITLE: Basic PIN Entry Form Example
DESCRIPTION: Demonstrates a simple Formik form with the FormikPinField component for basic PIN entry and submission.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/forms/FormikPinField.stories.mdx#_snippet_1
LANGUAGE: tsx
CODE:
```
import { Form, Formik } from 'formik';
import Button from '../Button';
import FormikPinField from './FormikPinField';
// Basic PIN entry form
console.log(values)}
>
```
--------------------------------
TITLE: Basic Action Menu Example
DESCRIPTION: Demonstrates the basic usage of the Dropdown component to create an action menu with clickable items.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Dropdown.stories.mdx#_snippet_1
LANGUAGE: tsx
CODE:
```
import Dropdown from './Dropdown';
// Assuming handleEdit and handleDelete are defined elsewhere
const handleEdit = () => console.log('Edit clicked');
const handleDelete = () => console.log('Delete clicked');
```
--------------------------------
TITLE: Collapsible with Buttons Example
DESCRIPTION: An example showcasing the Collapsible component with string-based primary and secondary buttons, including their respective click handlers.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Collapsible.stories.mdx#_snippet_7
LANGUAGE: tsx
CODE:
```
import React, { useState } from 'react';
// Assuming Collapsible component is imported
// import Collapsible from 'your-library';
export const Buttons = () => {
const [open, setOpen] = useState(false)
return (
{
setOpen(!open)
}}
staticContent="Static content"
closedContent="Closed content"
primary="Primary"
secondary="Secondary"
onPrimaryClick={() => alert('Primary button was pushed')}
onSecondaryClick={() => alert('Secondary button was clicked')}
>
Dynamic content
)
}
```
--------------------------------
TITLE: Basic Button Navigation Example
DESCRIPTION: Demonstrates how to use the Navigation component with basic button items, including setting labels, click handlers, and active states.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Navigation.stories.mdx#_snippet_1
LANGUAGE: tsx
CODE:
```
import Navigation from './Navigation';
// Assuming 'navigate' is a function for routing
const MyNavigation = () => (
navigate('/home'),
active: true
},
{
type: 'button',
key: 'about',
label: 'About',
onClick: () => navigate('/about')
}
]}
/>
);
```
--------------------------------
TITLE: Default Toggle Example
DESCRIPTION: A basic example of the Toggle component used for bold text formatting, featuring a 'Bold' icon from 'lucide-react'.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Toggle.stories.mdx#_snippet_1
LANGUAGE: react
CODE:
```
import { Bold } from 'lucide-react'
import { Toggle } from './Toggle'
export const Default = () => {
return (
)
}
```
--------------------------------
TITLE: Quick Info Hover Card Example
DESCRIPTION: An example of using HoverCard with custom delays to display a quick informational tip.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/HoverCard.stories.mdx#_snippet_3
LANGUAGE: tsx
CODE:
```
import { Button } from './Button'
import { HoverCard, HoverCardContent, HoverCardTrigger } from './HoverCard'
// Quick info hover card
Pro Tip: You can use keyboard shortcuts to navigate faster.
```
--------------------------------
TITLE: Tooltip Component API Documentation
DESCRIPTION: API documentation for the Tooltip component, detailing its props, structure, and usage examples.
SOURCE: https://github.com/uzh-bf/design-system/blob/main/packages/design-system/src/Tooltip.stories.mdx#_snippet_0
LANGUAGE: APIDOC
CODE:
```
Tooltip Component API Documentation:
Overview:
Enhanced contextual information overlay component built on Shadcn UI primitives with custom styling, delay control, flexible content support, and comprehensive accessibility features.
Dependencies:
- Shadcn UI Tooltip primitives for behavior and accessibility
- React node support for custom content rendering
- CSS styling system for tooltip appearance and arrow
- Positioning system for tooltip placement
- Testing attribute support for trigger and content
Available Stories:
- Default: Basic tooltip with string content
- MultiLine: Tooltip on text content with wrapping
- Styled: Custom styling for tooltip and arrow colors
- Children: React node content with custom components
- Delay: Custom delay timing before tooltip appears
Props (Tooltip component):
- id?: string - HTML id attribute for the tooltip
- data?: Record - Data attributes for trigger testing (e.g. data-test or data-cy)
- dataContent?: Record - Data attributes for tooltip content testing (e.g. data-test or data-cy)
- tooltip: string | React.ReactNode - Content to display in the tooltip
- delay?: number - Delay in milliseconds before tooltip appears
- children: React.ReactNode - Element that triggers the tooltip
- className?: Record - Styling overrides for tooltip and arrow (e.g., { tooltip: 'bg-green-600 text-white font-semibold', arrow: 'fill-green-600' })
Component Structure:
- Trigger element (children) with hover/focus detection
- Tooltip overlay positioned relative to trigger
- Arrow pointing to trigger element
- Automatic positioning based on available space
- Keyboard and mouse interaction support
Usage Examples:
// Basic tooltip with string content
// Icon with explanatory tooltip
// Complex content with React nodes
Pro Tip:
Use Ctrl+K to open the search quickly
}
>
// Custom delay for different UX needs
// Custom styled tooltip
// Form field help