Getting started
Installation
Add Cristal to a React or Next.js project.
Install the packages
npm install @cristal-ui/reactOne package is enough: it brings the components (@cristal-ui/core) and the design tokens.
Cristal is not published on npm yet. In the meantime, install the packages from the archives generated by pnpm pack (see the repository README).
Import the tokens
Once, at the root of the application: app/layout.tsx with Next.js, main.tsx with React.
import '@cristal-ui/react/tokens.css';Choose the language
The components' built-in texts (error messages, buttons, screen reader announcements) are in English by default. They switch to French when the component or one of its ancestors has lang="fr": the simplest way is to set it on the page.
<html lang="fr">lang can also be set on a single area (<section lang="en">) or on one component. The texts you provide (label, hint, error, options…) stay as you wrote them.
Use a component
React
import { CrButton } from '@cristal-ui/react';
export function Toolbar() {
return <CrButton onClick={() => alert('Saved')}>Save</CrButton>;
}Next.js
In a server component, import from @cristal-ui/react/ssr: the component is rendered on the server, with no flash on load.
import { CrButton } from '@cristal-ui/react/ssr';In a client component ('use client'), import from @cristal-ui/react.
Listen to events
Components emit events prefixed with cr. In React, listen to them with onCr…; the value is in event.detail.
<CrInput label="Search" onCrInput={(event) => setQuery(event.detail)} />