# OG UI > Open-source UI components as CSS classes (plus a 3 KB behaviour script and optional React wrappers) that read one theme contract, so the same markup renders in 7 design themes: clean, glass, liquid-glass, neumorphism, clay, brutal, aurora. Set data-og-theme / data-og-mode on (or any element). Components only read --og-* CSS variables. Rules for writing OG UI markup: - Use the og-* classes exactly as documented; don't add your own colours or shadows, read --og-* variables instead. - Call initOgUI() once (from @og-ui/core/og-ui.js) for menus, tabs, sliders, dialogs' data-og-open/close and toasts. - Dialogs are , popovers use the popover attribute, accordions are
, form controls are native inputs. - Give icon buttons an aria-label; give every input a visible label. # Installation OG UI is CSS classes that read a theme contract, plus a 3 KB script for the few behaviours HTML can't do alone. Pick one way in. ## Copy the files into your project (recommended) The CLI copies themes and components into your project, so you own the code, like shadcn/ui. ```bash npx @og-ui/cli init # default theme + base styles + og-ui/index.css npx @og-ui/cli add button dialog # component CSS npx @og-ui/cli add tabs --react # plus the React source npx @og-ui/cli theme glass # another theme; switch with data-og-theme="glass" ``` Then import `og-ui/index.css` once, in your root layout or main file. The CLI keeps files you have changed unless you pass `--overwrite`. ## Or with the shadcn CLI Every item is in shadcn's registry format, so the shadcn CLI installs it too: ```bash npx shadcn add https://ui.ogom.in/r/og-ui.json npx shadcn add https://ui.ogom.in/r/button.json ``` ## Or from npm ```bash npm i @og-ui/tokens @og-ui/core ``` ```js import '@og-ui/tokens/themes.css'; // all seven themes import '@og-ui/core/og-ui.css'; // every component import { initOgUI } from '@og-ui/core/og-ui.js'; initOgUI(); // keyboard for menus and tabs, sliders, toasts ``` ## React ```bash npm i @og-ui/react @og-ui/core @og-ui/tokens ``` ```tsx // app/layout.tsx (Next.js app router) import '@og-ui/tokens/themes.css'; import '@og-ui/core/og-ui.css'; import { ThemeProvider } from '@og-ui/react'; export default function RootLayout({ children }) { return ( {children} ); } ``` The components are thin, typed wrappers over the same classes. They forward refs, pass native props through and are safe to render on the server. ## Pick a theme and mode Set attributes on `` (or any element, to theme one section): ```html ``` - `data-og-theme`: clean (default), glass, liquid-glass, neumorphism, clay, brutal, aurora - `data-og-mode`: light, dark, or leave it out to follow the system - `data-og-density`: comfortable (default) or compact - `--og-accent`: any colour re-tints every theme, e.g. `style="--og-accent: #0ea5e9"` # Theming Components never read raw colours or shadows. They read semantic roles from one **theme contract** ("a raised surface", "the accent", "the press effect"), and every theme fills that contract in. Switching themes therefore never touches component code. ## The contract A theme has a **feel**, shared by both modes, and a **light** and **dark** mode. **Colour roles** (per mode): `bg`, `bgImage`, `bgSize`, `text`, `textMuted`, `onTint`, `border`, `accent`, `accentContrast`, `accentBorder`, `focusRing`, `success`, `warning`, `danger`, and a six-colour `palette` for tags, avatars, charts and tinted cards. **Surfaces** (per mode): three materials, `raised` (cards, buttons), `inset` (inputs, wells, tracks) and `overlay` (dialogs, popovers, toasts). Each has `bg`, `bgSolid` (the opaque fallback for reduced transparency), `border`, `shadow` (two layers at most), `backdrop` (blur: overlay only) and `highlight` (an effect layer under the content, used for glass shine, clay sheen and textures). **Effect** (per mode): `glow` around accent controls. **Feel**: radii (`sm`, `md`, `lg`, `full`, `control`), `borderWidth`, three font families (body, display, mono), `fontWeightStrong`, `tintStrength`, `pressTransform`, `hoverTransform`, `duration` and `easing`. Every field becomes a CSS variable: `--og-color-text`, `--og-surface-raised-shadow`, `--og-radius-control` and so on. The live table below shows every value for the theme you pick. ## Write your own theme A theme is one TypeScript file. `defineTheme` type-checks it against the contract, so a missing field is a compile error. ```ts // packages/tokens/src/themes/paper.ts import { defineTheme } from '../contract.js'; import { accent, accentContrast, fonts, noGlow, palettes, status } from '../shared.js'; export default defineTheme({ name: 'paper', label: 'Paper', description: 'Cream paper, ink outlines, no shadows.', feel: { radius: { sm: '2px', md: '4px', lg: '6px', full: '9999px', control: '4px' }, borderWidth: '1.5px', fontFamily: fonts.sans, fontFamilyDisplay: 'Georgia, serif', fontFamilyMono: fonts.mono, tintStrength: '18%', fontWeightStrong: '600', pressTransform: 'translateY(1px)', hoverTransform: 'none', duration: '120ms', easing: 'ease-out', }, modes: { light: { color: { bg: '#fbf7ee', bgImage: 'none', bgSize: 'auto', text: '#1c1917', onTint: '#1c1917', textMuted: '#57534e', border: '#1c1917', accent: accent('#b45309'), accentContrast: accentContrast('#ffffff'), accentBorder: '#1c1917', focusRing: accent('#b45309'), ...status.light, palette: [...palettes.light], }, effect: { glow: noGlow }, surface: { raised: { bg: '#fffdf8', bgSolid: '#fffdf8', border: '#1c1917', shadow: 'none', backdrop: 'none', highlight: 'none' }, inset: { bg: '#f5efe2', bgSolid: '#f5efe2', border: '#1c1917', shadow: 'none', backdrop: 'none', highlight: 'none' }, overlay: { bg: '#fffdf8', bgSolid: '#fffdf8', border: '#1c1917', shadow: '4px 4px 0 #1c1917', backdrop: 'none', highlight: 'none' }, }, }, dark: { /* the same shape with dark values */ }, }, }); ``` Then add it to `src/themes/index.ts` and run `pnpm build`. It's compiled to `themes.css`, to `themes/paper.css` on its own, and to JSON for other platforms. ## Check it ```bash pnpm --filter @og-ui/tokens contrast # WCAG 2.2 AA: text, muted text, accent, focus ring, surfaces, badges pnpm test # axe in every theme and mode, plus keyboard tests pnpm test:perf # theme-switch time, scroll FPS, hover cost on 3,000 components ``` ## Rules a theme must keep - `focusRing` has 3:1 contrast against `bg`; text pairs reach 4.5:1. - Shadows have two layers at most. They are the main paint cost. - Only `overlay` may blur (`backdrop`). Repeated elements fake glass with a translucent fill. - `bgSolid` must look right on `bg`: it replaces translucent fills when people ask for reduced transparency. - Motion is transform, opacity and colour only. OG UI turns hover and press motion off under `prefers-reduced-motion`. ## Theme one section Themes nest: any element with `data-og-theme` (and optionally `data-og-mode`) re-themes everything inside it. That's how this site shows each component in all seven themes on one page. # Components ## Button Actions. Default, primary, ghost and danger, in three sizes, plus a square icon button. Install: npx @og-ui/cli add button ### Variants ```html ``` ### Sizes ```html ``` ### Icon and disabled ```html ``` ### React ```tsx import { Button } from '@og-ui/react'; ``` ### Keyboard and screen readers - Tab focuses it; Enter and Space activate it (native ``` ### Tints ```html

Roadmap

12 open items

Revenue

Up 8% this month

``` ### React ```tsx import { Card, Button } from '@og-ui/react'; Send} > ₹4,200 for design work in November. ``` ### Keyboard and screen readers - Not focusable itself; Tab moves through the controls inside. ## Surface The three materials every theme defines: raised, inset and overlay. Build your own components on them. Install: npx @og-ui/cli add surface ### Materials ```html
Raised
Inset
Overlay
``` ### React ```tsx // No wrapper needed: use the classes.
…
``` ### Keyboard and screen readers - Presentational only. ## Input Text fields and textareas with a visible label, hint and invalid state. Install: npx @og-ui/cli add input ### Field ```html ``` ### Invalid and multiline ```html ``` ### React ```tsx import { Input } from '@og-ui/react'; ``` ### Keyboard and screen readers - Native input: Tab to focus, typing as usual. - Link the error text with aria-describedby so screen readers read it with the field. ## Select A styled native ``` ### React ```tsx import { Select } from '@og-ui/react'; ``` ### Keyboard and screen readers - Tab focuses; arrow keys change the value; Alt+Down (Windows) or Space opens the list. ## Checkbox and radio Native checkboxes and radios, restyled, including the indeterminate state and radio groups. Install: npx @og-ui/cli add checkbox ### Checkboxes ```html ``` ### Radio group ```html
Billing
``` ### React ```tsx import { Checkbox } from '@og-ui/react'; ``` ### Keyboard and screen readers - Space toggles a checkbox. - A radio group is one Tab stop; arrow keys move and select within it. - Group radios in a fieldset with a legend so the group name is announced. ## Switch An on/off setting that applies at once: a checkbox with role="switch". Install: npx @og-ui/cli add switch ### Switch ```html ``` ### React ```tsx import { Switch } from '@og-ui/react'; ``` ### Keyboard and screen readers - Space toggles. Screen readers announce “switch, on/off”. ## Slider A native range input whose filled track follows the thumb. Install: npx @og-ui/cli add slider ### Slider ```html ``` ### React ```tsx import { Slider } from '@og-ui/react'; ``` ### Keyboard and screen readers - Arrow keys step by 1; Page Up/Down by 10%; Home and End jump to the ends. - Add aria-valuetext when the number needs a unit (“62 percent”). - og-ui.js keeps the fill in sync while dragging. ## Dialog and drawer Modal : the browser traps focus, handles Esc and returns focus to the trigger. Drawers slide from an edge. Install: npx @og-ui/cli add dialog ### Dialog ```html

Delete project?

This removes all 24 files. You can’t undo it.

``` ### Drawer ```html

Filters

``` ### React ```tsx import { Dialog, Button } from '@og-ui/react'; const [open, setOpen] = useState(false); Delete} /> // Drawer: ``` ### Keyboard and screen readers - Opening moves focus into the dialog (first focusable control). - Tab stays inside; the page behind is inert. - Esc closes; focus returns to the button that opened it. - Buttons with data-og-close close it; clicking the backdrop closes it. - For destructive dialogs consider autofocus on Cancel. ## Popover and menu Native popover API (light dismiss, Esc, top layer), placed next to its trigger. A menu is a popover with role="menu". Install: npx @og-ui/cli add popover ### Popover ```html
Share this project

Anyone with the link can view it.

``` ### Menu ```html ``` ### React ```tsx import { Popover, Menu, MenuItem, MenuSeparator, Button } from '@og-ui/react'; Share}>Anyone with the link can view it. Actions ▾} label="Project actions"> Rename Delete ``` ### Keyboard and screen readers - Enter or Space on the trigger opens it; a menu focuses its first item. - Menu: Down/Up move (and wrap), Home/End jump to the first/last item. - Esc closes and returns focus to the trigger; choosing an item does too. - Tab closes a menu and moves on. ## Tooltip A CSS-only label on hover and keyboard focus. Esc hides it. Install: npx @og-ui/cli add tooltip ### Tooltip ```html ``` ### React ```tsx // No wrapper needed: ``` ### Keyboard and screen readers - Shows on focus. Esc hides it without moving focus (WCAG 1.4.13); it returns after focus leaves. - The tooltip is decorative: put the same text in the control’s aria-label. ## Toast Notifications in one polite live region; errors use role="alert". They pause while hovered or focused. Install: npx @og-ui/cli add toast ### Trigger a toast ```html ``` ### React ```tsx import { useToast } from '@og-ui/react'; const toast = useToast(); toast('Invoice sent', { variant: 'success', description: 'Acme Ltd will get it in a minute.' }); ``` ### Keyboard and screen readers - Focus is never moved to a toast. The Dismiss button is reachable at the end of the page. - Toasts close after 4 s; use duration: 0 for anything people must act on (WCAG 2.2.1). - Call initOgUI() at start-up so the live region exists before the first toast. ## Alert Inline messages in four tones. Install: npx @og-ui/cli add alert ### Tones ```html

Payment received

₹4,200 from Acme Ltd landed in your account.

Card expires soon

Update it before 1 January.

``` ### React ```tsx import { Alert } from '@og-ui/react'; Update it before 1 January. ``` ### Keyboard and screen readers - Not focusable. role="status" is announced politely; use role="alert" only for urgent errors. ## Progress A native ; leave out value for an indeterminate bar. Install: npx @og-ui/cli add progress ### Determinate and indeterminate ```html ``` ### React ```tsx import { Progress } from '@og-ui/react'; ``` ### Keyboard and screen readers - Not focusable. Give it an aria-label. ## Skeleton Placeholders while content loads. Install: npx @og-ui/cli add skeleton ### Shapes ```html
``` ### React ```tsx import { Skeleton } from '@og-ui/react'; ``` ### Keyboard and screen readers - Hidden from screen readers; set aria-busy on the region that is loading. ## Tabs WAI-ARIA tabs with automatic activation and roving focus. Install: npx @og-ui/cli add tabs ### Tabs ```html
Name, photo and timezone.
``` ### React ```tsx import { Tabs } from '@og-ui/react'; console.log(v)} /> ``` ### Keyboard and screen readers - The tab list is one Tab stop (only the selected tab has tabindex="0"). - Left/Right move between tabs and select them (Up/Down with aria-orientation="vertical"); they wrap. - Home/End go to the first/last tab. - Tab moves from the tab list into the panel. ## Accordion Native
: works without JavaScript. The same name keeps one item open. Install: npx @og-ui/cli add accordion ### One open at a time ```html
What is OG UI?
One component library with seven design themes.
Does it need React?
No. It’s CSS classes plus a 3 KB script; React wrappers are optional.
Is it accessible?
Every theme is contrast-checked and every component keyboard-tested.
``` ### React ```tsx import { Accordion, AccordionItem } from '@og-ui/react'; One library, seven themes. No. ``` ### Keyboard and screen readers - Tab moves between headers; Enter or Space opens and closes. ## Table Data tables that scroll sideways on small screens; compact density tightens rows. Install: npx @og-ui/cli add table ### Table ```html
InvoiceClientStatusAmount
#1042Acme LtdPending₹4,200
#1041NorthwindPaid₹12,800
#1040GlobexOverdue₹2,150
``` ### React ```tsx import { Table } from '@og-ui/react';
InvoiceAmount
#1042₹4,200
``` ### Keyboard and screen readers - A plain table: screen readers navigate it with their table commands. Use for headers. ## Pagination Page links in a labelled nav with the current page marked. Install: npx @og-ui/cli add pagination ### Pagination ```html ``` ### React ```tsx import { Pagination } from '@og-ui/react'; // or links: getHref={(p) => `?page=${p}`} ``` ### Keyboard and screen readers - Tab moves through the links; Enter follows one. A disabled link stays focusable but does nothing.