### Navigate to Project Directory
Source: https://preview.keenthemes.com/metronic8/react/docs/index
Changes the current directory to the specified React demo path. This is the first step before installing dependencies.
```bash
cd [unpacked path]/react/[demo]
```
--------------------------------
### Install Project Dependencies
Source: https://preview.keenthemes.com/metronic8/react/docs/index
Installs local project dependencies required for the React application. Dependencies are listed in package.json and installed into the node_modules folder.
```bash
npm install
# OR
yarn install
```
--------------------------------
### Start Development Server
Source: https://preview.keenthemes.com/metronic8/react/docs/index
Launches the development server, which watches for file changes and rebuilds the application automatically. The app can then be accessed at http://localhost:5173/.
```bash
npm run dev
# OR
yarn dev
```
--------------------------------
### Basic React-Select Examples
Source: https://preview.keenthemes.com/metronic8/react/docs/react-select
Provides basic examples of the React-Select component with different background styles (default, transparent, solid). It includes defining options and rendering the Select component with a placeholder.
```javascript
import { FC } from "react";
import Select from 'react-select'
const Example1: FC = () => {
const options = [
{ value: 'option 1', label: 'Option 1' },
{ value: 'option 2', label: 'Option 2' },
{ value: 'option 3', label: 'Option 3' },
{ value: 'option 4', label: 'Option 4' },
{ value: 'option 5', label: 'Option 5' },
]
return (
<>
>
)
}
export { Example1 };
```
--------------------------------
### Symbol Component Sizing Examples
Source: https://preview.keenthemes.com/metronic8/react/docs/symbol
This snippet provides examples of various sizes for the Symbol component. Sizes are controlled by classes like `symbol-{size}` (e.g., `symbol-50px`) and responsive variants like `symbol-{breakpoint}-{size}`. The examples show different pixel dimensions applied to the symbol.
```jsx
A
A
A
A
A
A
```
--------------------------------
### Install React Dependencies
Source: https://preview.keenthemes.com/metronic8/react/docs/rtl
Installs necessary React dependencies and extra webpack plugins required for RTL CSS generation. This command should be run after navigating to the specific demo folder within the Metronic React project.
```bash
npm install
```
--------------------------------
### React Modal Example with Flatpickr
Source: https://preview.keenthemes.com/metronic8/react/docs/flatpickr
This example demonstrates integrating the Flatpickr datepicker within a Bootstrap modal. It includes instructions on how to use `data-bs-focus="false"` to prevent focus issues when the modal initializes. The code shows a button to launch the modal, which contains the Flatpickr component.
```typescript
const Example8: FC = () => {
const [dateState, setDateState] = useState({
date: new Date()
});
return <>
Modal title
Select date
{
setDateState({ date });
}}
className='form-control form-control-solid'
placeholder='Pick date'
/>
>
}
```
--------------------------------
### Navigate to Demo Folder
Source: https://preview.keenthemes.com/metronic8/react/docs/rtl
Command to change the current directory to the specific Metronic React demo folder (e.g., `demo1`). This is typically the first step before running installation or build commands.
```bash
cd theme/react/demo1
```
--------------------------------
### Generate RTL CSS with Webpack
Source: https://preview.keenthemes.com/metronic8/react/docs/rtl
Executes an npm script command to run webpack, which will generate the RTL version of the CSS files. This script is part of the RTL setup process.
```bash
npm run rtl
```
--------------------------------
### Disabled React-Select Examples
Source: https://preview.keenthemes.com/metronic8/react/docs/react-select
Demonstrates disabled state examples for the React-Select component with default, transparent, and solid background styles. The `isDisabled` prop is used to disable user interaction.
```javascript
import { FC } from "react";
import Select from 'react-select'
const Example2: FC = () => {
const options = [
{ value: 'option 1', label: 'Option 1' },
{ value: 'option 2', label: 'Option 2' },
{ value: 'option 3', label: 'Option 3' },
{ value: 'option 4', label: 'Option 4' },
{ value: 'option 5', label: 'Option 5' },
]
return (
<>
>
)
}
export { Example2 };
```
--------------------------------
### Basic Breadcrumb Example (React)
Source: https://preview.keenthemes.com/metronic8/react/docs/breadcrumb
Demonstrates a basic breadcrumb structure using an ordered list with linked list items. This example assumes a React environment and utilizes Bootstrap classes for styling.
```jsx
```
--------------------------------
### Basic Flatpickr Examples in React
Source: https://preview.keenthemes.com/metronic8/react/docs/flatpickr
Demonstrates basic usage of the Flatpickr component in React with default and solid background input styles. It utilizes the `useState` hook to manage the selected date and includes placeholders for user interaction.
```javascript
const Example1: FC = () => {
const [dateState, setDateState] = useState({
date1: new Date(),
date2: new Date()
});
return (
<>
{
setDateState({ date1 });
}}
className='form-control'
placeholder='Pick date'
/>
{
setDateState({ date2 });
}}
className='form-control form-control-solid'
placeholder='Pick date'
/>
>
)
}
```
--------------------------------
### Apply Opacity Active State Classes in HTML
Source: https://preview.keenthemes.com/metronic8/react/docs/helpers/opacity
These HTML examples showcase the application of opacity classes for active states. Clicking on these elements will trigger a change in their opacity, providing visual cues for user interaction.
```html
```
--------------------------------
### Basic Bootstrap Modal Example in React
Source: https://preview.keenthemes.com/metronic8/react/docs/modal
This snippet demonstrates how to implement a basic Bootstrap Modal in a React application using Metronic's components. It includes the button to trigger the modal and the modal's HTML structure with header, body, and footer.
```jsx
Modal title
Modal body text goes here.
```
--------------------------------
### Basic Alert Example in React
Source: https://preview.keenthemes.com/metronic8/react/docs/alerts
Demonstrates a basic alert component in React using Metronic's styling. It includes an icon and text content, utilizing primary alert coloring. This component is suitable for general informational messages.
```jsx
...
This is an alert
The alert component can be used to highlight certain parts of your page for higher content visibility.
```
--------------------------------
### React Flushed Button Example
Source: https://preview.keenthemes.com/metronic8/react/docs/buttons
Illustrates a 'flushed' button using the `.btn-flush` class, which removes paddings, borders, background, and rounded corners for a minimalist appearance.
```JSX
Flushed button
```
--------------------------------
### Enable Multi-Selection in React-Select
Source: https://preview.keenthemes.com/metronic8/react/docs/react-select
This example demonstrates how to enable multi-selection in a React-Select component using the `isMulti` attribute. It shows variations for small, default, and large sizes, allowing users to select multiple options and display them as tags. It takes an array of options and a placeholder.
```jsx
import { FC } from "react";
import Select from 'react-select'
const Example9: FC = () => {
const options = [
{ value: 'option 1', label: 'Option 1' },
{ value: 'option 2', label: 'Option 2' },
{ value: 'option 3', label: 'Option 3' },
{ value: 'option 4', label: 'Option 4' },
{ value: 'option 5', label: 'Option 5' },
]
return (
<>
>
)
}
export { Example9 };
```
--------------------------------
### Fullscreen Bootstrap Modal Example in React
Source: https://preview.keenthemes.com/metronic8/react/docs/modal
This snippet shows how to create a fullscreen Bootstrap Modal in React using Metronic. It utilizes the `.modal-fullscreen` class for the fullscreen effect and applies `.bg-white` and `.shadow-none` for styling long, scrollable content.
```jsx
Modal title
Modal body text goes here.
```
--------------------------------
### React: Display Basic Star Rating with Duotune Icons
Source: https://preview.keenthemes.com/metronic8/react/docs/rating
Demonstrates how to render a basic star-based rating component in React using Duotune SVG icons. This example shows how to apply the 'checked' class to indicate a filled star.
```jsx
```
--------------------------------
### Apply Circle Style to Symbol
Source: https://preview.keenthemes.com/metronic8/react/docs/symbol
This example shows how to apply a circular style to the Symbol component using the `symbol-circle` class. It also demonstrates setting the background image using inline styles and the `toAbsoluteUrl` function.
```jsx
```
--------------------------------
### Group Select Options with React-Select
Source: https://preview.keenthemes.com/metronic8/react/docs/react-select
This example shows how to group options in a react-select dropdown. It utilizes the 'options' property within each group object to define the selectable choices. The component requires 'react-select' for functionality and renders a select input with predefined option groups.
```javascript
import { FC } from "react";
import Select from 'react-select'
const Example3: FC = () => {
const groupedOptions = [
{
label: 'Group 1',
options: [
{ value: 'option 1 - group 1', label: 'Option 1' },
{ value: 'option 2 - group 1', label: 'Option 2' },
{ value: 'option 3 - group 1', label: 'Option 3' },
{ value: 'option 4 - group 1', label: 'Option 4' },
{ value: 'option 5 - group 1', label: 'Option 5' },
]
},
{
label: 'Group 2',
options: [
{ value: 'option 1 - group 2', label: 'Option 1' },
{ value: 'option 2 - group 2', label: 'Option 2' },
{ value: 'option 3 - group 2', label: 'Option 3' },
{ value: 'option 4 - group 2', label: 'Option 4' },
{ value: 'option 5 - group 2', label: 'Option 5' },
]
}
]
return (
)
}
export { Example3 };
```
--------------------------------
### React Base Button Styles
Source: https://preview.keenthemes.com/metronic8/react/docs/buttons
Demonstrates how to apply base button styles using the `.btn-{color}` class, which are defined by Metronic's SASS variables `$theme-colors`. These examples show different color options for anchor tag buttons.
```jsx
WhitePrimaryLightSecondarySuccessInfoWarningDangerDark
```
--------------------------------
### Display Text Labels with Symbol
Source: https://preview.keenthemes.com/metronic8/react/docs/symbol
This example showcases how to use the Symbol component to display text-based labels. It involves styling the `.symbol-label` element with utility classes for font size, weight, color, and background. Multiple variations demonstrate different text and background color combinations.
```jsx
A
L
C
T
X
S
```
--------------------------------
### Toggling Indicator State with JavaScript (React)
Source: https://preview.keenthemes.com/metronic8/react/docs/indicator
Provides a React code example for dynamically toggling the Indicator component's state using the 'useRef' hook and JavaScript. It illustrates how to attach an event listener to a button and use 'setTimeout' to simulate a progress indication that automatically deactivates after a few seconds.
```javascript
// import {useRef} from 'react';
// in your function add rows =>
const btnRef = useRef(null);
const onClick = () => {
// Disable indicator after 3 seconds
btnRef.current?.setAttribute('data-kt-indicator', 'on');
setTimeout(() => {
// Activate indicator
btnRef.current?.removeAttribute("data-kt-indicator");
}, 3000);
};
// in your HTML add
```
--------------------------------
### Configure React Router for Custom Page
Source: https://preview.keenthemes.com/metronic8/react/docs/create-a-page
This code demonstrates how to update the React Router configuration to include a new route for the custom page. It involves importing the page component and adding a new Route element within the existing Routes structure. Ensure `react-router-dom` is installed and configured.
```tsx
import {lazy, FC, Suspense} from 'react'
import {Route, Routes, Navigate} from 'react-router-dom'
import {MasterLayout} from '../../_metronic/layout/MasterLayout'
import {DashboardWrapper} from '../pages/dashboard/DashboardWrapper'
import {MenuTestPage} from '../pages/MenuTestPage'
+ import {MyPage} from "../pages/MyPage"
export function PrivateRoutes() {
const BuilderPageWrapper = lazy(() => import('../pages/layout-builder/BuilderPageWrapper'))
const ProfilePage = lazy(() => import('../modules/profile/ProfilePage'))
const WizardsPage = lazy(() => import('../modules/wizards/WizardsPage'))
const AccountPage = lazy(() => import('../modules/accounts/AccountPage'))
const WidgetsPage = lazy(() => import('../modules/widgets/WidgetsPage'))
const ChatPage = lazy(() => import('../modules/apps/chat/ChatPage'))
return (
return (
}>
{/* Redirect to Dashboard after success login/registartion */}
} />
{/* Pages */}
+} />
} />
} />
} />
{/* Lazy Modules */}
}
/>
}
/>
}
/>
}
/>
}
/>
{/* Page Not Found */}
} />
)
}
```
--------------------------------
### Enable Dark Mode SCSS Import in React
Source: https://preview.keenthemes.com/metronic8/react/docs/dark-mode
This snippet shows how to replace the default SCSS import with the dark mode SCSS file in the `index.tsx` file to enable dark mode styling. This is a direct replacement of one import statement.
```typescript
- import './_metronic/assets/sass/style.scss'
+ import './_metronic/assets/sass/style.dark.scss'
```
--------------------------------
### Basic Indicator Component Implementation (HTML)
Source: https://preview.keenthemes.com/metronic8/react/docs/indicator
Demonstrates the basic implementation of the Indicator component using HTML. It shows how to structure the button with separate spans for the label and progress message, and how to activate the indicator using the 'data-kt-indicator="on"' attribute.
```html
```
--------------------------------
### React: Custom Sized Form Switches
Source: https://preview.keenthemes.com/metronic8/react/docs/forms
Provides examples of form switches with custom dimensions using Metronic's height ('h-') and width ('w-') utility classes. This allows for precise control over the switch's visual size, accommodating various design requirements. The examples show 20x30px, 30x50px, and 40x60px configurations.
```jsx
```
--------------------------------
### Range Selection in Flatpickr React
Source: https://preview.keenthemes.com/metronic8/react/docs/flatpickr
Shows how to implement range date selection in Flatpickr. The `mode` option is set to 'range', allowing users to select a start and end date. The `onChange` event provides an array containing the start and end dates, managed via `useState`. Note that disabled dates are not selectable in range mode.
```javascript
const Example5: FC = () => {
const [dateState, setDateState] = useState({
startDate: new Date(),
endDate: new Date()
});
return <>
{
setDateState({ startDate, endDate });
}}
options={{
mode: "range"
}}
className='form-control form-control-solid'
placeholder='Pick date'
/>
>
}
```
--------------------------------
### Toggle Active State and Rotate Icons
Source: https://preview.keenthemes.com/metronic8/react/docs/rotate
Provides examples of buttons where clicking toggles the 'active' class on the button element itself, dynamically rotating the associated icon. This utilizes an inline `onClick` handler to manage the class toggle. Note that some examples show the icon rotating to 90 degrees regardless of the button's intended rotation.
```jsx
```
--------------------------------
### Card with Border
Source: https://preview.keenthemes.com/metronic8/react/docs/cards
This example shows a card with a border instead of a shadow, achieved by adding the `.card-border` class. This is useful for creating distinct visual separations.
```html
Title
Lorem Ipsum is simply dummy text...
Footer
```
--------------------------------
### React: Build Nested Layouts with Flex Classes
Source: https://preview.keenthemes.com/metronic8/react/docs/helpers/flex-layout
Demonstrates using Metronic's responsive flex classes in React to create nested layouts with fixed and fluid columns. This example showcases various combinations of flex properties like `flex-row-auto`, `flex-column-fluid`, and `flex-center` to control layout dimensions and content alignment. No external dependencies beyond React itself are required for these classes.
```jsx
Fixed Height
Fluid Height
Fixed Height
Fluid Width
Fixed Width
```
--------------------------------
### Metronic Width & Height Utility Classes (HTML)
Source: https://preview.keenthemes.com/metronic8/react/docs/utilities
These classes provide responsive control over an element's width and height properties, including min/max values. They utilize a `{property}-{size}` format and support responsive breakpoints.
```html
```
--------------------------------
### Create React Page Component
Source: https://preview.keenthemes.com/metronic8/react/docs/create-a-page
This snippet shows how to create a basic React functional component for a new page. It defines the component's structure and its JSX return value. No external dependencies beyond React are required for this basic component.
```tsx
import React from "react";
export function MyPage() {
return
Hello!
}
```
--------------------------------
### React Flex Button with Icon and Text
Source: https://preview.keenthemes.com/metronic8/react/docs/buttons
Shows a button styled with `.btn-flex` to vertically center its content. This example includes an SVG icon and text with a description, utilizing flexbox properties.
```JSX
CaptionSome description
```
--------------------------------
### Disable Search in React-Select
Source: https://preview.keenthemes.com/metronic8/react/docs/react-select
This example shows how to disable the search functionality in a React-Select component by setting the `isSearchable` attribute to `false`. This is useful when you want to provide a simple dropdown without search input. It requires an array of options and a placeholder.
```jsx
import { FC } from "react";
import Select from 'react-select'
const Example7: FC = () => {
const options = [
{ value: 'option 1', label: 'Option 1' },
{ value: 'option 2', label: 'Option 2' },
{ value: 'option 3', label: 'Option 3' },
{ value: 'option 4', label: 'Option 4' },
{ value: 'option 5', label: 'Option 5' },
]
return (
)
}
export { Example7 };
```
--------------------------------
### React: Basic Overlay Effect with Buttons
Source: https://preview.keenthemes.com/metronic8/react/docs/overlay
This snippet demonstrates how to implement a basic overlay effect on images using the `.overlay`, `.overlay-wrapper`, and `.overlay-layer` classes in React. It includes buttons within the overlay layer for interaction. The overlay background color and opacity can be adjusted using utility classes like `.bg-dark .bg-opacity-10`.
```jsx
```
--------------------------------
### Basic Pulse Component Implementation in React
Source: https://preview.keenthemes.com/metronic8/react/docs/pulse
Demonstrates the fundamental usage of the Pulse component to highlight elements. It requires React and the KTSVG component for icon rendering. The output is an anchor tag with the 'pulse' class applied.
```jsx
```
--------------------------------
### Import React-Select Component
Source: https://preview.keenthemes.com/metronic8/react/docs/react-select
This snippet shows how to import the core React-Select component for use in your React application. No external dependencies are required beyond React itself.
```javascript
import Select from 'react-select'
```
--------------------------------
### Basic React Pagination Component
Source: https://preview.keenthemes.com/metronic8/react/docs/pagination
This React component renders a basic Bootstrap-styled pagination UI. It includes previous and next navigation links, along with numbered page links. The active page is visually distinguished. No external libraries are explicitly required beyond React itself.
```jsx
```
--------------------------------
### Set Border Gray Colors (React)
Source: https://preview.keenthemes.com/metronic8/react/docs/helpers/borders
Shows how to set custom border colors using Metronic's gray scale utility classes, ranging from `.border-gray-100` to `.border-gray-900`. These examples are presented in a React context.
```jsx
```
--------------------------------
### React: Display Star Rating with Bootstrap Icons
Source: https://preview.keenthemes.com/metronic8/react/docs/rating
Illustrates how to implement a star rating component in React using Bootstrap Icons. This example utilizes the 'bi bi-star' class and the 'checked' modifier for filled stars.
```jsx