Click UIGetting started

Getting started

Get up and running with Click UI in your React application. This guide covers installation, setup, and your first component.

Installation

Install Click UI using npm or yarn:

npm install @clickhouse/click-ui
# or
yarn add @clickhouse/click-ui

Setup

1. Styles

There is no CSS file to import. Click UI ships its styles as CSS Modules next to each component, so importing a component also brings in its styles. Most React setups (Vite, Next.js, TanStack Start) handle CSS Modules out of the box.

Next.js needs one extra setting so it can process the package’s CSS:

// next.config.js
module.exports = {
  transpilePackages: ['@clickhouse/click-ui'],
}

Click UI has three peer dependencies: react, react-dom and dayjs. If your package manager does not install peer dependencies for you, add dayjs to your app.

2. Wrap your app with ClickUIProvider

All Click UI components must be wrapped in the ClickUIProvider. This provides theme context and required providers for tooltips and toasts.

import { ClickUIProvider, ThemeName } from '@clickhouse/click-ui'
import { useState } from 'react'

function App() {
  const [theme, setTheme] = useState<ThemeName>('dark')

  return (
    <ClickUIProvider theme={theme}>
      {/* Your app content */}
    </ClickUIProvider>
  )
}

Your first component

Here’s a complete example showing how to use Click UI components:

Welcome to Click UI

This is your first Click UI component!

dark theme

Complete example code

import { ClickUIProvider, Container, Title, Text, Button, Switch, ThemeName } from '@clickhouse/click-ui'
import { useState } from 'react'

function App() {
  const [theme, setTheme] = useState<ThemeName>('dark')
  const [count, setCount] = useState(0)

  return (
    <ClickUIProvider theme={theme}>
      <Container orientation='vertical' gap='md' padding='lg'>
        <Title type='h1' size='lg'>Welcome to Click UI</Title>
        <Text>This is your first Click UI component!</Text>
        
        <Container orientation='horizontal' gap='sm' alignItems='center'>
          <Switch
            checked={theme === 'dark'}
            onCheckedChange={(checked) => setTheme(checked ? 'dark' : 'light')}
            label='Dark mode'
          />
        </Container>

        <Button 
          type='primary' 
          label={`Clicked ${count} times`}
          onClick={() => setCount(count + 1)}
        />
      </Container>
    </ClickUIProvider>
  )
}

export default App

Framework-specific setup

Next.js

In Next.js, add @clickhouse/click-ui to transpilePackages (see Styles), then wrap your app in pages/_app.tsx or app/layout.tsx:

// pages/_app.tsx
import { ClickUIProvider, ThemeName } from '@clickhouse/click-ui'
import { useState } from 'react'
import type { AppProps } from 'next/app'

export default function MyApp({ Component, pageProps }: AppProps) {
  const [theme, setTheme] = useState<ThemeName>('dark')

  return (
    <ClickUIProvider theme={theme}>
      <Component {...pageProps} />
    </ClickUIProvider>
  )
}

Vite / Create React App

In Vite or CRA, wrap your app in main.tsx or index.tsx:

// main.tsx
import { ClickUIProvider, ThemeName } from '@clickhouse/click-ui'
import { useState } from 'react'
import React from 'react'
import ReactDOM from 'react-dom/client'

function App() {
  const [theme, setTheme] = useState<ThemeName>('dark')

  return (
    <ClickUIProvider theme={theme}>
      <YourApp />
    </ClickUIProvider>
  )
}

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
)

Provider configuration

The ClickUIProvider accepts an optional config prop to customize tooltip and toast behavior:

<ClickUIProvider 
  theme={theme}
  config={{
    tooltip: { delayDuration: 0 },
    toast: { align: 'start' }
  }}
>
  {/* Your app */}
</ClickUIProvider>

Important notes

  • Provider Required: All Click UI components must be wrapped in ClickUIProvider
  • No CSS import: Styles load with each component. Next.js apps must add @clickhouse/click-ui to transpilePackages
  • Controlled Components: Most form components are controlled - manage state externally
  • Button Labels: Use the label prop, not children: <Button label="Click me" />
  • Table Structure: Tables use headers (array) and rows (array with id and items)
  • Form Handlers: Form inputs use onChange with value parameter: onChange={(value) => setValue(value)}

Next steps

Need help?

© 2026 ClickHouse, Inc. HQ in the Bay Area, CA and Amsterdam, NL.