### CDN Setup with esm.sh for VKUI Source: https://github.com/vkcom/vkui/blob/master/website/content/overview/install.mdx Example of how to use VKUI with esm.sh via HTML links and import maps. This method is recommended for quick prototyping. ```html ``` -------------------------------- ### Install Playwright Browsers Source: https://github.com/vkcom/vkui/blob/master/docs/TESTING.md Installs necessary browsers for Playwright testing. This command should be run before starting Playwright tests. ```bash yarn run playwright:install ``` -------------------------------- ### VKUI Hello World Example Source: https://github.com/vkcom/vkui/blob/master/README.md A basic 'Hello World' example demonstrating the structure of a VKUI application. It includes essential components like ConfigProvider, AdaptivityProvider, AppRoot, and a simple View with a Panel. ```jsx import * as React from 'react'; import { createRoot } from 'react-dom/client'; import { AdaptivityProvider, ConfigProvider, AppRoot, SplitLayout, SplitCol, View, Panel, PanelHeader, Header, Group, SimpleCell, usePlatform } from '@vkontakte/vkui'; import '@vkontakte/vkui/dist/vkui.css'; const Example = () => { const platform = usePlatform(); return ( }> VKUI Items}> Hello World ); }; const container = document.getElementById('root'); const root = createRoot(container); // createRoot(container!) if you use TypeScript root.render( , ); ``` -------------------------------- ### Install VKUI with pnpm Source: https://github.com/vkcom/vkui/blob/master/README.md Use this command to install the VKUI library using pnpm. ```sh pnpm add @vkontakte/vkui ``` -------------------------------- ### Install VKUI with yarn Source: https://github.com/vkcom/vkui/blob/master/README.md Use this command to install the VKUI library using yarn. ```sh yarn add @vkontakte/vkui ``` -------------------------------- ### Run Project in Development Mode Source: https://github.com/vkcom/vkui/blob/master/examples/vkui-vite-ts/README.md Start the development server to see your application in real-time. ```bash yarn dev ``` -------------------------------- ### Install VKUI with npm Source: https://github.com/vkcom/vkui/blob/master/README.md Use this command to install the VKUI library using npm. ```sh npm i @vkontakte/vkui ``` -------------------------------- ### Install Dependencies Source: https://github.com/vkcom/vkui/blob/master/examples/vkui-vite-ts/README.md Install project dependencies using Yarn. ```bash yarn install ``` -------------------------------- ### Basic ContentCard Example Source: https://github.com/vkcom/vkui/blob/master/website/content/components/content-card.mdx A basic example of ContentCard with an image, text blocks, and a click handler. Use this for standard card layouts. ```jsx {}} src="https://images.unsplash.com/photo-1603988492906-4fb0fb251cf8?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1600&q=80" alt="Picture of brown and gray mountains under blue sky during daytime photo" overTitle="unsplash" title="brown and gray mountains under blue sky during daytime photo" description="Mountain changji" caption="Photo by Siyuan on Unsplash" maxHeight={100} /> ``` -------------------------------- ### UsersStack with Block Start Avatars and Count Source: https://github.com/vkcom/vkui/blob/master/website/content/components/users-stack.mdx Example of UsersStack with avatars positioned above the text ('block-start') and a participant counter. Recommended to use with size='m'. ```jsx Виктория, Эльдар и ещё 3 человека пойдут на это мероприятие ``` -------------------------------- ### Install VKUI Docs Theme Source: https://github.com/vkcom/vkui/blob/master/packages/vkui-docs-theme/README.md Install the necessary packages for VKUI Docs Theme using npm, yarn, or pnpm. ```sh # npm npm i react react-dom next nextra @vkontakte/vkui-docs-theme # yarn yarn add react react-dom next nextra @vkontakte/vkui-docs-theme # or pnpm pnpm add react react-dom next nextra @vkontakte/vkui-docs-theme ``` -------------------------------- ### Basic Pagination Example Source: https://github.com/vkcom/vkui/blob/master/website/content/components/pagination.mdx Displays a basic Pagination component with the current page and total number of pages. ```jsx ``` -------------------------------- ### Demonstrating ScreenSpinner States Source: https://github.com/vkcom/vkui/blob/master/website/content/components/screen-spinner.mdx Provides examples of ScreenSpinner in various states: loading, cancelable, done, error, and custom with a specific icon. ```jsx }> ``` -------------------------------- ### Complex Skeleton Example in Cell and Text Block Source: https://github.com/vkcom/vkui/blob/master/website/content/components/skeleton.mdx Demonstrates a complex Skeleton setup within a cell and a text block, simulating a loading state for a group of items. It shows how to use Skeleton for avatars, subtitles, and main text. ```jsx } subtitle={} >
``` -------------------------------- ### Basic DateInput Example Source: https://github.com/vkcom/vkui/blob/master/website/content/components/date-input.mdx A basic DateInput component for manual date entry and calendar selection. ```jsx ``` -------------------------------- ### Import and Use Button Component Source: https://github.com/vkcom/vkui/blob/master/website/content/overview/usage.mdx Demonstrates how to import and use the Button component from VKUI. Ensure you have installed the VKUI library. ```jsx import { Button } from '@vkontakte/vkui'; export default function App() { return ( ); } ``` -------------------------------- ### Minimal FocusTrap Setup Source: https://github.com/vkcom/vkui/blob/master/website/content/components/focus-trap.mdx Shows the most basic implementation of FocusTrap. Ensure the root element has `tabIndex={-1}` to be focusable. ```jsx const focusTrapRef = React.useRef(null); return (
); ``` -------------------------------- ### Install VKUI MCP Server Locally Source: https://github.com/vkcom/vkui/blob/master/website/content/overview/mcp.mdx Install the VKUI MCP server as a development dependency in your project using npm or yarn. This allows you to fix the version used in your project. ```bash npm install -D @vkontakte/vkui-mcp # или yarn add -D @vkontakte/vkui-mcp ``` -------------------------------- ### Basic Screen Navigation with View Source: https://github.com/vkcom/vkui/blob/master/website/content/overview/navigation.mdx Implement basic screen transitions within a scenario using the View component. This example demonstrates switching between two panels using buttons. ```jsx import { useState } from 'react'; import { View, Panel, PanelHeader, Button } from '@vkontakte/vkui'; export const Router = () => { const [activePanel, setActivePanel] = useState('panel-1'); return ( Панель 1 Панель 2 ); }; ``` -------------------------------- ### Basic SubnavigationBar Example Source: https://github.com/vkcom/vkui/blob/master/website/content/components/subnavigation-bar.mdx A basic SubnavigationBar with a set of buttons for quick section switching. Use this for simple navigation within a section. ```jsx {}}>Мой размер {}}>В наличии {}}>Высокий рейтинг {}}>Избранное ``` -------------------------------- ### Basic Navigation with Panels and Views Source: https://github.com/vkcom/vkui/blob/master/website/content/overview/usage.mdx Illustrates implementing basic navigation between screens using VKUI's SplitLayout, SplitCol, View, and Panel components. This setup is suitable for mobile applications. ```jsx import { useState } from 'react'; import { SplitLayout, SplitCol, View, Panel, PanelHeader, Group, CellButton, usePlatform, } from '@vkontakte/vkui'; const [activePanel, setActivePanel] = useState('feed-panel'); const platform = usePlatform(); return ( }> Лента setActivePanel('profile-panel')}>Перейти в Профиль } stretched > Профиль setActivePanel('feed-panel')}>Вернуться в Ленту} stretched > ``` -------------------------------- ### Basic Accordion Example Source: https://github.com/vkcom/vkui/blob/master/website/content/components/accordion.mdx A simple Accordion with a summary and content. Use this for basic collapsible content sections. ```jsx import { Accordion, Div } from '@vkontakte/vkui'; Новый дизайн профиля
Внешний вид профиля ВКонтакте действительно обновился. К прежнему варианту вернуться уже не получится. В центре внимания нового дизайна — личность человека и его увлечения. Новый формат профиля особенно удобен для авторов контента и станет для них цифровой визиткой.
``` -------------------------------- ### Input Component Structure Source: https://github.com/vkcom/vkui/blob/master/docs/CONTRIBUTING.md Shows an example of an Input component where the `input` element is the main element, not its wrapper, for prop handling. ```jsx import styles from './Input.module.css'; const Input = ({ mode, style, className, ...restProps }) => { return (
); }; ``` -------------------------------- ### Gradient Overlay Example Source: https://github.com/vkcom/vkui/blob/master/website/content/components/gradient.mdx Demonstrates using the Gradient component as an overlay on top of content for visual accent. The gradient is positioned absolutely to cover the entire area. ```jsx } title="Алексей Мазелюк" action={} > Учащийся ``` -------------------------------- ### Configure Next.js Scripts Source: https://github.com/vkcom/vkui/blob/master/packages/vkui-docs-theme/README.md Add scripts to your package.json for running Next.js development, build, and start commands. ```json "scripts": { "dev": "next", "build": "next build", "start": "next start" } ``` -------------------------------- ### Basic WriteBar with Attach Icon Source: https://github.com/vkcom/vkui/blob/master/website/content/components/write-bar.mdx A simple WriteBar example with an attachment icon in the 'before' slot. Use this for a straightforward message input with a single leading action. ```jsx } placeholder="Введите сообщение..." /> ``` -------------------------------- ### Live Debugging with Playwright Source: https://github.com/vkcom/vkui/blob/master/docs/TESTING.md Starts Playwright DevTools and the specified browser for live debugging. Configure the desired project and test file in the `.env` file before running. ```bash yarn test:e2e:ci --debug ``` -------------------------------- ### Banner with Avatar, Title, Subtitle, and Button Source: https://github.com/vkcom/vkui/blob/master/website/content/components/banner.mdx A basic example of a Banner displaying an avatar, title, subtitle, and a primary action button. ```jsx } title="Новое уведомление" subtitle="У вас 5 новых сообщений" actions={} /> ``` -------------------------------- ### FormItem with Label, Input, and Bottom Hint Source: https://github.com/vkcom/vkui/blob/master/website/content/components/form-item.mdx This example demonstrates a complete FormItem structure including a label, input, and a hint message in the `bottom` prop. The `bottomId` should be linked to an accessible element if needed. ```jsx const id = React.useId() const bottomId = React.useId() return ( ); ``` -------------------------------- ### Custom Snackbar Without Additional Props Example Source: https://github.com/vkcom/vkui/blob/master/website/content/components/use-snackbar-manager.mdx Demonstrates rendering a simple custom snackbar component directly via `openCustom` without passing any extra data. ```jsx const SnackbarComponent = ({ update, close, snackbarProps, }: CustomSnackbar.Props) => { return ( Сообщение отправлено ); }; const [snackbarApi, snackbarHolder] = useSnackbarManager(); const showSnackbar = () => { snackbarApi.openCustom(SnackbarComponent); }; return ( <> {snackbarHolder} ); ``` -------------------------------- ### Setting Platform Theme with ConfigProvider Source: https://github.com/vkcom/vkui/blob/master/website/content/overview/themes.mdx Example of how to explicitly set the platform theme to 'ios' using the ConfigProvider component. This ensures components visually adapt to the iOS platform. ```jsx import { ConfigProvider, AdaptivityProvider, AppRoot, SimpleCell } from '@vkontakte/vkui'; import '@vkontakte/vkui/dist/vkui.css'; Темным-темно ``` -------------------------------- ### WriteBar with Before, After, and InlineAfter Elements Source: https://github.com/vkcom/vkui/blob/master/website/content/components/write-bar.mdx An example of WriteBar configured with elements in the 'before', 'after', and 'inlineAfter' slots. This allows for multiple actions and indicators around the input field. ```jsx } after={ } inlineAfter={ } placeholder="Введите сообщение..." /> ``` -------------------------------- ### usePagination Hook Example Source: https://github.com/vkcom/vkui/blob/master/website/content/components/pagination.mdx Manually renders pagination elements using the usePagination hook. This provides full control over the UI and integration with custom logic. ```jsx const items = usePagination({ totalPages: 10, currentPage: 5, }); // items → [1, 'start-ellipsis', 4, 5, 6, 'end-ellipsis', 10] return ( ); ``` -------------------------------- ### Basic Onboarding Tooltip Source: https://github.com/vkcom/vkui/blob/master/website/content/components/onboarding-tooltip.mdx Demonstrates the basic usage of OnboardingTooltip for a one-time introduction to a new feature. It wraps an element and displays a description when shown. ```jsx import { OnboardingTooltipWrapper } from '@/components/wrappers'; ``` -------------------------------- ### Tooltip with aria-hidden and disableTriggerOnFocus Source: https://github.com/vkcom/vkui/blob/master/website/content/components/tooltip.mdx Example of a Tooltip configured with `aria-hidden="true"` and `disableTriggerOnFocus`. This setup restricts activation solely to hover events, making it suitable for purely decorative elements. ```jsx ``` -------------------------------- ### Adaptive Tabbar using useAdaptivityConditionalRender Source: https://github.com/vkcom/vkui/blob/master/website/content/components/epic.mdx This example demonstrates how to conditionally render a `Tabbar` only on tablet and larger screens using the `useAdaptivityConditionalRender` hook. This is useful for adapting UI to different device sizes. ```jsx import { useAdaptivityConditionalRender } from '@vkontakte/vkui'; import { Epic, Tabbar, TabbarItem, View, Panel, PanelHeader, Placeholder } from '@vkontakte/vkui'; import { Icon28NewsfeedOutline, Icon28UserCircleOutline } from '@vkontakte/icons'; export default function App() { const { viewWidth } = useAdaptivityConditionalRender(); const [activeStory, setActiveStory] = React.useState('feed'); return ( setActiveStory('feed')}> setActiveStory('profile')}> ) } > Лента Профиль ); } ``` -------------------------------- ### Build Project for Production Source: https://github.com/vkcom/vkui/blob/master/examples/vkui-vite-ts/README.md Generate a production-ready build of your application. ```bash yarn build ``` -------------------------------- ### App Layout Setup Source: https://github.com/vkcom/vkui/blob/master/website/content/overview/navigation.mdx Set up the main application layout using SplitLayout and SplitCol for safe area compliance and proper spacing on different screen sizes. This wrapper should be placed near the application's root. ```jsx import { SplitLayout, SplitCol, PanelHeader } from '@vkontakte/vkui'; export default function App() { return ( }> {/* ... */} ); }; ``` -------------------------------- ### Header with Various Icon Slots and Controls Source: https://github.com/vkcom/vkui/blob/master/website/content/components/group.mdx An advanced example of the Header component showcasing usage of `before`, `beforeTitle`, `afterTitle`, `beforeSubtitle`, `afterSubtitle` slots for icons, along with a subtitle, indicator, and a link. ```jsx } beforeTitle={} afterTitle={} beforeSubtitle={} afterSubtitle={} subtitle="SOHN — Conrad" subtitleComponent="h3" indicator={ 3 } after={Показать все} > Плейлисты } >
Контент
``` -------------------------------- ### Using CSS Variables for Theming Source: https://github.com/vkcom/vkui/blob/master/website/content/overview/themes.mdx Demonstrates how to apply theme colors and backgrounds using CSS variables provided by VKUI. ```css .SomeComponent { color: var(--vkui--color_text_primary); background: var(--vkui--color_background_content); } ``` -------------------------------- ### Basic CellButton Example Source: https://github.com/vkcom/vkui/blob/master/website/content/components/cell-button.mdx A basic example of CellButton used for an action within a list. ```jsx {}}>Добавить родственника ``` -------------------------------- ### Vertical Separator Example Source: https://github.com/vkcom/vkui/blob/master/website/content/components/separator.mdx To use a vertical separator, ensure the parent container is a flex container. This example shows vertical separators between links. ```jsx Новости Звонки Друзья ``` -------------------------------- ### Playwright Error Example Source: https://github.com/vkcom/vkui/blob/master/docs/TESTING.md An example error message from Playwright indicating an issue with resolving an exported component. This often suggests a cache problem. ```sh vkui-package_vkui-1 | $ playwright test --config playwright-ct.config.ts -u vkui-package_vkui-1 | vkui-package_vkui-1 | Running 10 tests using 2 workers vkui-package_vkui-1 | vkui-package_vkui-1 | vite v4.2.1 building for production... vkui-package_vkui-1 | transforming... vkui-package_vkui-1 | Error when using sourcemap for reporting an error: Can't resolve original location of error. vkui-package_vkui-1 | ✓ 2616 modules transformed. vkui-package_vkui-1 | ✓ built in 3.67s vkui-package_vkui-1 | "AccordionE2EPlayground" is not exported by "src/components/Accordion/Accordion.e2e-playground.tsx", imported by "playwright/index.tsx". ``` -------------------------------- ### Creating Wrappers for ModalPage/ModalCard Source: https://github.com/vkcom/vkui/blob/master/website/content/components/modal-root.mdx Demonstrates how to create wrapper components for ModalPage and ModalCard. Business logic should be handled within the modal or via useModalRootContext. The example shows fetching data asynchronously and conditionally enabling effects based on the active modal. ```jsx const SomeAsyncEffect = () => { const [data, setData] = useState({}); useEffect(function fetchData() { // Здесь логика, которая должна вызываться при показе окна fetch("...") .then((r) => r.json()) .then(setData); }, []); return
{data}
; }; const ModalPageWrapper = ({ id, ...restProps }) => { const { activeModal } = useModalRootContext(); useEffect( function enableSomeEffect() { if (id === activeModal) { // Здесь логика, которая должна вызываться при показе окна } }, [id, activeModal] ); return ( ); }; const App = () => { return ( {/* или */} ); }; ``` -------------------------------- ### Screenshot Test Example with expectScreenshotClippedToContent Source: https://github.com/vkcom/vkui/blob/master/docs/TESTING.md This example demonstrates how to use `expectScreenshotClippedToContent` for taking screenshots in Playwright tests. It shows how multiple calls within the same test generate sequentially numbered screenshots. ```typescript test('base', ({ expectScreenshotClippedToContent }) => { // ... await expectScreenshotClippedToContent(); }); test('Example', async ({ expectScreenshotClippedToContent }) => { // ... await expectScreenshotClippedToContent(); // => мы получим скриншот с названием 'example-android-chromium-light-1-snap.png' await expectScreenshotClippedToContent(); // => мы получим скриншот с названием 'example-android-chromium-light-2-snap.png' }); test.describe('Example', () => { test('My AWESOME case description', async ({ expectScreenshotClippedToContent }) => { // ... await expectScreenshotClippedToContent(); // => мы получим скриншот с названием 'example-android-chromium-light-my-awesome-case-description-1-snap.png' }); }); ``` -------------------------------- ### Gradient Accessibility - Bad vs Good Practice Source: https://github.com/vkcom/vkui/blob/master/website/content/components/gradient.mdx Illustrates incorrect and correct ways to use the Gradient component with text. The bad example places text directly inside the gradient, while the good example separates the gradient and text for better accessibility. ```jsx // ❌ Плохо (градиент содержит текст) Важная информация // ✅ Хорошо (текст вынесен отдельно)
Важная информация
``` -------------------------------- ### Basic ModalRoot Usage Source: https://github.com/vkcom/vkui/blob/master/website/content/components/modal-root.mdx Demonstrates how to set up and use ModalRoot with ModalPage and ModalCard components. Use this to manage the visibility and transitions of different modal views. ```jsx const [activeModal, setActiveModal] = React.useState(null); const close = () => setActiveModal(null); const modalRoot = ( } /> } /> ); return ( <> {modalRoot} ); ``` -------------------------------- ### Basic CellButtonGroup Example Source: https://github.com/vkcom/vkui/blob/master/website/content/components/cell-button-group.mdx A group of two CellButtons with a separator for related actions. ```jsx {}}> Пожаловаться {}}> Отмена ``` -------------------------------- ### Basic DropZone with File Handling Source: https://github.com/vkcom/vkui/blob/master/website/content/components/drop-zone.mdx Demonstrates a basic DropZone that handles file drops and displays the names of the uploaded files. Ensure to prevent default behavior for drag over and drop events. ```jsx { event.preventDefault(); }} onDrop={(event) => { event.preventDefault(); const files = event.dataTransfer.files; const fileNames = Array.from(files).map((file) => file.name); alert(`Файлы: \n${fileNames.join('\n')}`); }} > Перенесите файл сюда для быстрой отправки. ``` -------------------------------- ### Disabled Switch Source: https://github.com/vkcom/vkui/blob/master/website/content/components/switch.mdx An example of a disabled Switch component, preventing user interaction and indicating unavailability. ```jsx ``` -------------------------------- ### Download Template by Cloning Repository Source: https://github.com/vkcom/vkui/blob/master/examples/vkui-vite-ts/README.md Clone the VKUI repository and navigate to the template directory. ```bash git clone https://github.com/VKCOM/VKUI.git cd VKUI/examples/vkui-vite-ts ``` -------------------------------- ### Demonstrate Adaptive Icon Rendering Source: https://github.com/vkcom/vkui/blob/master/website/content/components/adaptive-icon-renderer.mdx Shows how AdaptiveIconRenderer automatically selects icon sizes for 'compact' and 'regular' interface densities. It uses AdaptivityProvider to simulate different densities. ```jsx Icon size 24 Icon size 28 ``` -------------------------------- ### Centered CellButton with Icon Source: https://github.com/vkcom/vkui/blob/master/website/content/components/cell-button.mdx Example of a centered CellButton that includes an icon using the `centered` prop and `before` slot. ```jsx {}} centered before={}> Центрированная кнопка ``` -------------------------------- ### Avatar with Custom Gradient Style Source: https://github.com/vkcom/vkui/blob/master/website/content/components/avatar.mdx Example of using custom styles for gradient backgrounds on avatars with initials. ```jsx ``` -------------------------------- ### Adaptive Icons and Dynamic Actions in WriteBar Source: https://github.com/vkcom/vkui/blob/master/website/content/components/write-bar.mdx This example showcases adaptive icons and dynamic behavior in WriteBar based on the input text. It uses `AdaptiveIconRenderer` to switch icons based on platform and input length, providing context-aware actions. ```jsx const [text, setText] = React.useState(''); const platform = usePlatform(); const SmileOutlineIcon = ( ); const VoiceOutlineIcon = ( ); const KeyboardBotsOutlineIcon = ( ); return ( setText(e.target.value)} before={} inlineAfter={ <> {text.length === 0 && ( {KeyboardBotsOutlineIcon} )} {text.length > 0 && ( {SmileOutlineIcon} )} } after={ <> {text.length === 0 && ( {SmileOutlineIcon} )} {text.length === 0 && ( {VoiceOutlineIcon} )} {text.length > 0 && } } placeholder="Сообщение" /> ); ``` -------------------------------- ### Assembling ScreenSpinner from Subcomponents Source: https://github.com/vkcom/vkui/blob/master/website/content/components/screen-spinner.mdx Shows how to construct a ScreenSpinner using its individual subcomponents: Container, Loader, and SwapIcon. ```jsx ``` -------------------------------- ### AI User Prompt for VKUI v8 Migration (Brief) Source: https://github.com/vkcom/vkui/blob/master/website/content/migrations/migration-v8.mdx A concise prompt for an AI assistant to check code for VKUI v8 migration. It instructs the AI to use migration targets and apply before/after replacements based on component and prop similarity. ```text Проверь этот код на миграцию VKUI v8. Действуй так: вызови list_migration_targets, затем для каждого компонента из списка, который есть в моём коде, вызови get_migration_target и примени все рекомендации (замени фрагменты по полям before → after). Не пропускай компоненты: сверяй по именам и пропсам, а не по точному тексту примера. ``` -------------------------------- ### Centering HorizontalCellShowMore Source: https://github.com/vkcom/vkui/blob/master/website/content/components/horizontal-scroll.mdx Demonstrates how to center the HorizontalCellShowMore component within its parent using the 'centered' property. By default, it is aligned to the start. ```jsx ``` -------------------------------- ### TabsItem with Icons Source: https://github.com/vkcom/vkui/blob/master/website/content/components/tabs.mdx Demonstrates how to use the TabsItem component with icons in the 'before' and 'after' slots. Icons should match the mode requirements for size. ```jsx } after={}> Фото ``` -------------------------------- ### CellButton with Visually Hidden Text for Accessibility Source: https://github.com/vkcom/vkui/blob/master/website/content/components/cell-button.mdx Example of adding visually hidden text to a CellButton for improved screen reader accessibility. ```jsx Создать документ Нажмите Enter для активации ``` -------------------------------- ### Interactive App Navigation Example Source: https://github.com/vkcom/vkui/blob/master/website/content/overview/navigation.mdx Demonstrates a complex navigation structure with nested Views, Panels, and scenarios. It utilizes hooks like useAdaptivityConditionalRender and usePlatform for responsive design. This snippet is suitable for building multi-panel applications. ```tsx const App = () => { const [activeScenario, setActiveScenario] = useState('main-menu-scenario'); const goBack = () => setActiveScenario('main-menu-scenario'); return ( {label} } onClick={() => setActiveScenario('notification-scenario')} > Уведомления } onClick={() => setActiveScenario('about-scenario')} > О приложении
2 раздела
); }; const { viewWidth } = useAdaptivityConditionalRender(); const [activeTab, setActiveTab] = useState('profile'); const platform = usePlatform(); return ( } center> {viewWidth.tabletPlus && ( {platform !== 'vkcom' && } {tabConfig.map(({ id, label, Icon, Indicator }) => ( } indicator={Indicator ? : null} activated={activeTab === id} onClick={() => setActiveTab(id)} > {label} ))} )} {tabConfig.map(({ id, label, Icon, Indicator }) => ( : null} onClick={() => setActiveTab(id)} > ))} ) } > {tabConfig.map(({ id, label, PlaceholderIcon }) => { switch (id) { case 'more': return ; default: return ( {label} : null} /> ); } })} ); ``` -------------------------------- ### Next.js Configuration for VKUI Source: https://github.com/vkcom/vkui/blob/master/website/content/overview/install.mdx Configure Next.js to transpile VKUI and transform imports for CSS Modules. This setup is specific to Next.js projects. ```javascript module.exports = { // ... // Включаем транспиляцию transpilePackages: ['@vkontakte/vkui'], // Трансформируем импорты modularizeImports: { '@vkontakte/vkui': { transform: '@vkontakte/vkui/dist/cssm', skipDefaultConversion: true, }, }, }; ``` -------------------------------- ### Custom userEvent Setup for Jest Source: https://github.com/vkcom/vkui/blob/master/website/content/blog/testing-vkui-apps.mdx This helper configures `userEvent` for compatibility with the Jest testing environment, specifically addressing timer advancements. ```jsx import userEventLib from '@testing-library/user-event'; /** * Переконфигурируем работу userEvent под jest * * https://github.com/testing-library/user-event/issues/833 */ export const userEvent = userEventLib.setup({ advanceTimers: jest.advanceTimersByTime }); ``` -------------------------------- ### Clickable MiniInfoCell with Chevron for Settings Source: https://github.com/vkcom/vkui/blob/master/website/content/components/mini-info-cell.mdx An example of a MiniInfoCell with a chevron, specifically for clickable rows like profile settings, indicating an interactive element. ```jsx {}} before={}> Настройки профиля ``` -------------------------------- ### Disabled FormField Source: https://github.com/vkcom/vkui/blob/master/website/content/components/form-field.mdx Example of a FormField in a disabled state, preventing user interaction and providing visual feedback. The 'disabled' prop controls this state. ```jsx ``` -------------------------------- ### Basic Paragraph Usage Source: https://github.com/vkcom/vkui/blob/master/website/content/components/paragraph.mdx Demonstrates the basic usage of the Paragraph component for displaying main text content, suitable for long descriptions and multi-line content. ```jsx Основной текст абзаца. Используйте этот компонент для длинных описаний и многострочного контента. ``` -------------------------------- ### DateRangeInput with Validation Statuses Source: https://github.com/vkcom/vkui/blob/master/website/content/components/date-range-input.mdx Examples of DateRangeInput demonstrating 'error' and 'valid' status for visual validation feedback. These statuses are applied directly to the input. ```jsx ``` -------------------------------- ### Creating Multiple Views with Panels Source: https://github.com/vkcom/vkui/blob/master/website/content/overview/navigation.mdx Demonstrates how to create distinct scenarios using the View and Panel components. Use this to manage different sets of panels within a single story. ```jsx import { useState } from 'react'; import { View, Panel, PanelHeader, Button } from '@vkontakte/vkui'; export const FirstScenario = () => { const [activePanel, setActivePanel] = useState('first-panel-1'); return ( Панель 1 Панель 2 ); }; export const SecondScenario = () => { const [activePanel, setActivePanel] = useState('second-panel-1'); return ( Панель 1 Панель 2 ); }; ``` -------------------------------- ### Configure Themes with ColorSchemeProvider and Styles Source: https://github.com/vkcom/vkui/blob/master/website/content/overview/themes.mdx Demonstrates setting system, dark, and light themes for SimpleCell components. It shows how to apply a specific background color using inline styles when overriding themes for child components. ```jsx Настройка тем}> }>Системная тема } style={{ backgroundColor: 'var(--vkui--color_background_content)' }} > Тёмная тема } style={{ backgroundColor: 'var(--vkui--color_background_content)' }} > Светлая тема ``` -------------------------------- ### Banner with Image in Before Section and Dismiss Button Source: https://github.com/vkcom/vkui/blob/master/website/content/components/banner.mdx An example of a Banner using an Image component in the 'before' section and a 'dismiss' button in the 'after' section. ```jsx } title="Баста в Ледовом" subtitle="Большой концерт" after="dismiss" actions={} /> ``` -------------------------------- ### Get Current Content Direction with useDirection Source: https://github.com/vkcom/vkui/blob/master/website/content/components/direction-provider.mdx Use the `useDirection` hook to retrieve the current content direction value within your React components. ```jsx const direction = useDirection(); ```