### Start Development Server Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/guides/react-router.mdx Run the development server after completing Mantine setup. ```bash npm run dev ``` -------------------------------- ### Project Setup Source: https://github.com/mantinedev/mantine/blob/master/apps/help.mantine.dev/src/pages/q/how-can-i-contribute.mdx Run the initial project setup script. ```bash npm run setup ``` -------------------------------- ### Initialize Storybook Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/guides/storybook.mdx Use this command to add Storybook to your application if it's not already installed. This guide is for Storybook 10+. ```bash npx storybook@latest init ``` -------------------------------- ### Mantine Development Server Scripts Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/contribute.mdx Commands to start development servers for Storybook and the documentation site. An example is provided for starting Storybook for a specific component. ```bash storybook ``` ```bash npm run storybook Tooltip ``` ```bash docs ``` -------------------------------- ### Mantine Local Development Setup Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/contribute.mdx A sequence of commands to set up your local environment for Mantine development, including Node.js version management, dependency installation, and initial project builds. ```bash nvm use ``` ```bash yarn ``` ```bash npm run setup ``` ```bash npm run build ``` ```bash npm run storybook ``` ```bash npm run docs ``` ```bash npm run docs:docgen ``` -------------------------------- ### Install @mantinex/dev-icons with yarn or npm Source: https://github.com/mantinedev/mantine/blob/master/packages/@mantinex/dev-icons/README.md Install the @mantinex/dev-icons package using either yarn or npm. Choose the package manager that matches your project setup. ```bash # With yarn yarn add @mantinex/dev-icons ``` ```bash # With npm npm install @mantinex/dev-icons ``` -------------------------------- ### Install @mantinex/mantine-header with yarn or npm Source: https://github.com/mantinedev/mantine/blob/master/packages/@mantinex/mantine-header/README.md Install the @mantinex/mantine-header package using either yarn or npm. Choose the package manager that matches your project setup. ```bash # With yarn yarn add @mantinex/mantine-header ``` ```bash # With npm npm install @mantinex/mantine-header ``` -------------------------------- ### Fieldset Documentation Setup Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/core/fieldset.mdx Setup for the Fieldset documentation page using MDX layout and demo data. ```typescript import { FieldsetDemos } from '@docs/demos'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx'; export default Layout(MDX_DATA.Fieldset); ``` -------------------------------- ### NavLink Documentation Page Setup Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/core/nav-link.mdx Initial setup and layout configuration for the NavLink documentation page using MDX. ```javascript import { NavLinkDemos } from '@docs/demos'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx'; export default Layout(MDX_DATA.NavLink); ``` -------------------------------- ### Calendar Documentation Layout Setup Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/dates/calendar.mdx Initial setup for the Calendar documentation page using MDX layout and data. ```javascript import { CalendarDemos } from '@docs/demos'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx'; export default Layout(MDX_DATA.Calendar); ``` -------------------------------- ### Install @mantine/schedule with yarn and npm Source: https://github.com/mantinedev/mantine/blob/master/packages/@mantine/schedule/README.md Install @mantine/schedule and its required dependencies using either yarn or npm. Both commands install the same packages with identical peer dependencies. ```bash # With yarn yarn add @mantine/schedule @mantine/core @mantine/hooks @mantine/dates ``` ```bash # With npm npm install @mantine/schedule @mantine/core @mantine/hooks @mantine/dates ``` -------------------------------- ### Install @mantine/tiptap with npm Source: https://github.com/mantinedev/mantine/blob/master/packages/@mantine/tiptap/README.md Install @mantine/tiptap and its required dependencies using npm package manager. ```bash npm install @mantine/tiptap @mantine/core @mantine/hooks @tiptap/react @tiptap/extension-link ``` -------------------------------- ### Start Documentation Server Source: https://github.com/mantinedev/mantine/blob/master/apps/help.mantine.dev/src/pages/q/how-can-i-contribute.mdx Run the local development server for the Mantine documentation. ```bash npm run docs ``` -------------------------------- ### Start Gatsby development server Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/guides/gatsby.mdx Run the development server to start building your Mantine application with Gatsby. ```bash npm run develop ``` -------------------------------- ### Install Vitest and React Testing Library Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/guides/vitest.mdx Install necessary dev dependencies for testing in a Vite-based project. ```html ``` -------------------------------- ### Install @mantine/tiptap with yarn Source: https://github.com/mantinedev/mantine/blob/master/packages/@mantine/tiptap/README.md Install @mantine/tiptap and its required dependencies using yarn package manager. ```bash yarn add @mantine/tiptap @mantine/core @mantine/hooks @tiptap/react @tiptap/extension-link ``` -------------------------------- ### Start Storybook Source: https://github.com/mantinedev/mantine/blob/master/apps/help.mantine.dev/src/pages/q/how-can-i-contribute.mdx Launch the Storybook environment for component development and testing. ```bash npm run storybook ``` -------------------------------- ### Install @mantine/form package Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/form/package.mdx Install the @mantine/form package using npm or yarn. ```bash npm install @mantine/form # or ``` ```bash yarn add @mantine/form ``` -------------------------------- ### Documentation Page Setup Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/core/code.mdx Imports and layout configuration for the Code component documentation page. ```javascript import { CodeDemos } from '@docs/demos'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx'; export default Layout(MDX_DATA.Code); ``` -------------------------------- ### MDX Page Setup Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/core/loading-overlay.mdx Initial imports and layout configuration for the LoadingOverlay documentation page. ```javascript import { LoadingOverlayDemos } from '@docs/demos'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx'; export default Layout(MDX_DATA.LoadingOverlay); ``` -------------------------------- ### Install @mantine/charts with dependencies Source: https://github.com/mantinedev/mantine/blob/master/packages/@mantine/charts/README.md Use yarn or npm to install the charts package and its required peer dependencies. ```bash # With yarn yarn add @mantine/charts @mantine/core @mantine/hooks recharts # With npm npm install @mantine/charts @mantine/core @mantine/hooks recharts ``` -------------------------------- ### Install @mantine/emotion Source: https://github.com/mantinedev/mantine/blob/master/packages/@mantine/emotion/README.md Install the package and its peer dependencies using yarn or npm. ```bash # With yarn yarn add @mantine/emotion @mantine/core @mantine/hooks @emotion/react # With npm npm install @mantine/emotion @mantine/core @mantine/hooks @emotion/react ``` -------------------------------- ### useClipboard Hook Usage Example Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/hooks/use-clipboard.mdx Practical example demonstrating how to use the useClipboard hook to copy text to the clipboard and manage the copied state with automatic reset. ```APIDOC ## useClipboard Usage ### Description Basic usage pattern for the useClipboard hook to copy text and track the copy state. ### Example Implementation ```tsx import { useClipboard } from '@mantine/hooks'; function CopyButton() { const { copy, copied, error } = useClipboard(); return ( ); } ``` ### With Custom Timeout ```tsx const { copy, copied, reset } = useClipboard({ timeout: 3000 }); ``` ### With Error Handling ```tsx const { copy, copied, error, reset } = useClipboard(); if (error) { console.error('Failed to copy:', error); } ``` ``` -------------------------------- ### Install Mantine Form with yarn Source: https://github.com/mantinedev/mantine/blob/master/packages/@mantine/form/README.md Install @mantine/form package using yarn package manager. ```bash yarn add @mantine/form ``` -------------------------------- ### Install @mantine/modals Source: https://github.com/mantinedev/mantine/blob/master/packages/@mantine/modals/README.md Install the modals manager along with its required peer dependencies using Yarn or npm. ```bash # With yarn yarn add @mantine/hooks @mantine/core @mantine/modals ``` ```bash # With npm npm install @mantine/hooks @mantine/core @mantine/modals ``` -------------------------------- ### Install npm-check-updates globally Source: https://github.com/mantinedev/mantine/blob/master/apps/help.mantine.dev/src/pages/q/how-to-update-dependencies.mdx Install the ncu utility globally to use it as a standalone command for future dependency updates. ```sh npm install -g npm-check-updates ``` -------------------------------- ### Install updated dependencies with yarn Source: https://github.com/mantinedev/mantine/blob/master/apps/help.mantine.dev/src/pages/q/how-to-update-dependencies.mdx After updating package.json, run the install command to download the new versions of the packages. ```sh yarn ``` -------------------------------- ### BackgroundImage MDX Setup Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/core/background-image.mdx Required imports and layout export for the BackgroundImage documentation page. ```typescript import { BackgroundImageDemos } from '@docs/demos'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx'; export default Layout(MDX_DATA.BackgroundImage); ``` -------------------------------- ### Install @mantinex/demo package with Yarn or npm Source: https://github.com/mantinedev/mantine/blob/master/packages/@mantinex/demo/README.md This snippet demonstrates how to install the `@mantinex/demo` package using either Yarn or npm package managers. It provides the necessary commands for adding the package to your project's dependencies. ```bash yarn add @mantinex/demo ``` ```bash npm install @mantinex/demo ``` -------------------------------- ### Install @mantinex/colors-generator Source: https://github.com/mantinedev/mantine/blob/master/packages/@mantinex/colors-generator/README.md Add the package to your project using either yarn or npm package managers. ```bash # With yarn yarn add @mantinex/colors-generator # With npm npm install @mantinex/colors-generator ``` -------------------------------- ### Fieldset Usage Demo Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/core/fieldset.mdx Basic Fieldset component usage example. ```jsx ``` -------------------------------- ### Install @mantinex/mantine-meta package Source: https://github.com/mantinedev/mantine/blob/master/packages/@mantinex/mantine-meta/README.md Use yarn or npm to add the @mantinex/mantine-meta package to your project dependencies. ```bash # With yarn yarn add @mantinex/mantine-meta ``` ```bash # With npm npm install @mantinex/mantine-meta ``` -------------------------------- ### Setup Mantine List documentation layout in JavaScript Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/core/list.mdx Initializes the documentation page by importing demos and applying the List layout. ```javascript import { ListDemos } from '@docs/demos'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx'; export default Layout(MDX_DATA.List); ``` -------------------------------- ### Flex Documentation Page Setup Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/core/flex.mdx Initial imports and layout configuration for the Flex component documentation page. ```javascript import { FLEX_STYLE_PROPS_DATA } from '@mantine/core'; import { FlexDemos } from '@docs/demos'; import { StylePropsTable } from '@/components/StylePropsTable'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx'; export default Layout(MDX_DATA.Flex); ``` -------------------------------- ### Full Polymorphic Component Example with Mantine's polymorphicFactory Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/guides/custom-components.mdx This example demonstrates how to create a fully polymorphic component using `polymorphicFactory`, including defining props, styles, and a vars resolver. It shows the complete setup for a component whose root element can be changed. ```tsx import { Box, BoxProps, createVarsResolver, polymorphicFactory, PolymorphicFactory, StylesApiProps, useProps, useStyles, } from '@mantine/core'; import classes from './PolymorphicExample.module.css'; export type PolymorphicExampleStylesNames = 'root'; export type PolymorphicExampleVariant = string; export type PolymorphicExampleCssVariables = { root: '--test'; }; export interface PolymorphicExampleProps extends BoxProps, StylesApiProps {} export type PolymorphicExampleFactory = PolymorphicFactory<{ props: PolymorphicExampleProps; defaultRef: HTMLDivElement; defaultComponent: 'div'; stylesNames: PolymorphicExampleStylesNames; vars: PolymorphicExampleCssVariables; variant: PolymorphicExampleVariant; }>; const defaultProps = {} satisfies Partial; const varsResolver = createVarsResolver(() => ({ root: { '--test': 'test', }, })); export const PolymorphicExample = polymorphicFactory((_props) => { const props = useProps('PolymorphicExample', defaultProps, _props); const { classNames, className, style, styles, unstyled, vars, attributes, ...others } = props; const getStyles = useStyles({ name: 'PolymorphicExample', props, classes, className, style, classNames, styles, unstyled, attributes, vars, varsResolver, }); return ; }); PolymorphicExample.displayName = '@mantine/core/PolymorphicExample'; ``` -------------------------------- ### useInterval basic API usage Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/hooks/use-interval.mdx Import and use the useInterval hook to get control methods (start, stop, toggle) and active status. The hook requires a callback function and interval duration in milliseconds. ```typescript import { useInterval } from '@mantine/hooks'; const { start, stop, toggle, active } = useInterval(fn, interval); ``` -------------------------------- ### Access and Use Mantine Component Classes Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/changelog/7-0-0.mdx Access predefined component classes from the Component.classes object to apply Mantine styling to custom HTML elements. This example retrieves Button classes and applies the root class to a native button element. ```typescript import { Button } from '@mantine/core'; function Demo() { return ); } ``` -------------------------------- ### Vitest setup and browser API mocks Source: https://github.com/mantinedev/mantine/blob/master/apps/mantine.dev/src/pages/guides/vitest.mdx Mocks matchMedia and ResizeObserver APIs required by Mantine components in the jsdom environment. ```tsx import '@testing-library/jest-dom/vitest'; import { vi } from 'vitest'; const { getComputedStyle } = window; window.getComputedStyle = (elt) => getComputedStyle(elt); window.HTMLElement.prototype.scrollIntoView = () => {}; Object.defineProperty(window, 'matchMedia', { writable: true, value: vi.fn().mockImplementation((query) => ({ matches: false, media: query, onchange: null, addListener: vi.fn(), removeListener: vi.fn(), addEventListener: vi.fn(), removeEventListener: vi.fn(), dispatchEvent: vi.fn(), })), }); Object.defineProperty(document, 'fonts', { value: { addEventListener: vi.fn(), removeEventListener: vi.fn() }, }); class ResizeObserver { observe() {} unobserve() {} disconnect() {} } window.ResizeObserver = ResizeObserver; ``` -------------------------------- ### Emotion Nested Inline Styles Example Source: https://github.com/mantinedev/mantine/blob/master/apps/help.mantine.dev/src/pages/q/nested-inline-styles.mdx This example from Emotion documentation demonstrates the syntax for nested inline styles using the `css` prop, which is common in CSS-in-JS libraries. ```tsx render(
This has a hotpink background.
); ```