A set of complex React components built on top of @gravity-ui/uikit. Part of the Gravity UI design system.
npm install @gravity-ui/components@gravity-ui/uikit is a peer dependency: install it, import its styles once at the app entry point, and wrap the app in ThemeProvider. The components in this package render unstyled without that setup.
import {ThemeProvider, TextInput} from '@gravity-ui/uikit';
import {FormRow} from '@gravity-ui/components';
import '@gravity-ui/uikit/styles/fonts.css';
import '@gravity-ui/uikit/styles/styles.css';
export function App() {
return (
<ThemeProvider theme="light">
<FormRow label="Name" fieldId="name">
<TextInput id="name" name="name" />
</FormRow>
</ThemeProvider>
);
}import {ConfirmDialog} from '@gravity-ui/components';
<ConfirmDialog
open={open}
title="Delete the project?"
message="This cannot be undone."
textButtonApply="Delete"
textButtonCancel="Cancel"
onClickButtonApply={handleDelete}
onClickButtonCancel={() => setOpen(false)}
onClose={() => setOpen(false)}
/>;Every component has a README next to its source with props and examples — see src/components/<Component>/README.md. Live demos: Storybook.
git clone git@github.com:gravity-ui/components.git
cd components
npm ci
npm run start # launches Storybook at http://localhost:7009Other useful commands:
npm test # run unit tests
npm run lint # lint JS and SCSS
npm run typecheck # TypeScript type-checkContributions are welcome! Please read CONTRIBUTING.md before submitting a pull request.
Distributed under the MIT License. See LICENSE for details.
The composite-component layer of Gravity UI — ready-made form rows, confirmation dialogs, adaptive tabs, notifications, stories, galleries and similar product-level widgets assembled from @gravity-ui/uikit primitives, so you do not rebuild them by hand.
- Form layout:
FormRow(label + field + description) instead of a hand-made label/input wrapper. - Confirmation flows:
ConfirmDialoginstead of composingDialogwith two buttons yourself. - Tabs that must survive narrow containers:
AdaptiveTabs(overflow collapses into a select). - Product widgets:
Notifications,Stories/StoriesGroup,ChangelogDialog,OnboardingMenu,PromoSheet,CookieConsent,Reactions,SharePopover,StoreBadge. - Data helpers:
InfiniteScroll,ItemSelector,DelayedTextInput,TokenizedInput,Gallery.
- Basic controls, overlays, layout and theming — use
@gravity-ui/uikitdirectly; this package only adds composites on top of it. - Data grids — use
@gravity-ui/table; there is no table here. - Date pickers and calendars — use
@gravity-ui/date-components. - Application navigation shells (aside header, footer) — use
@gravity-ui/navigation. - Schema-driven forms — use
@gravity-ui/dynamic-forms;FormRowis only a layout row.
- Nothing is styled without uikit setup. Install
@gravity-ui/uikit, import@gravity-ui/uikit/styles/styles.css(plusfonts.css) once, and wrap the app inThemeProvider— this package ships no global styles of its own. FormRowdoes not render the input. Pass the control aschildrenand link it withfieldIdmatching the control'sid; thelabelprop is the label text, not a<label>element.ConfirmDialoghas noonConfirm/onCancel. The handlers areonClickButtonApplyandonClickButtonCancel, andtextButtonApply/textButtonCancelare required.AdaptiveTabstakesitems+activeTab+onSelectTab, not uikitTabschildren; thesizevalues arem | l | xl.- Hallucinated imports. Everything is exported from the package root:
import {FormRow} from '@gravity-ui/components'. There are no subpath imports like@gravity-ui/components/FormRow.
Agent-readable documentation for the installed version is located in node_modules/@gravity-ui/components/build/docs/INDEX.md.