Loading...
Loading...
Guide for using @geajs/ui — a Tailwind-styled, Zag.js-powered component library for the Gea framework. Use when building UIs with @geajs/ui components like Button, Select, Dialog, Tabs, Toast, or any pre-built component from the library.
npx skill4agent add dashersw/gea gea-ui-componentsreference.mdnpm install @geajs/core @geajs/ui
npm install -D vite @geajs/vite-plugin tailwindcss @tailwindcss/viteimport { defineConfig } from 'vite'
import { geaPlugin } from '@geajs/vite-plugin'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [geaPlugin(), tailwindcss()],
})import '@geajs/ui/style.css'import { Button, Select, Dialog, Toaster, ToastStore } from '@geajs/ui'ComponentclasschildrenZagComponentimport { Component } from '@geajs/core'
import { Button, Badge, Separator } from '@geajs/ui'
export default class App extends Component {
template() {
return (
<div>
<Button click={() => console.log('clicked')}>Save</Button>
<Button variant="destructive">Delete</Button>
<Button variant="outline" size="sm">Cancel</Button>
<Badge variant="secondary">Draft</Badge>
<Separator />
</div>
)
}
}valuecheckedopenonValueChangeonCheckedChangeonOpenChangeimport { Component } from '@geajs/core'
import { Select, Switch, Slider } from '@geajs/ui'
export default class Settings extends Component {
theme = ''
darkMode = false
volume = 50
template() {
return (
<div>
<Select
label="Theme"
items={[
{ value: 'light', label: 'Light' },
{ value: 'dark', label: 'Dark' },
{ value: 'system', label: 'System' },
]}
value={this.theme ? [this.theme] : []}
onValueChange={(d: any) => { this.theme = d.value[0] || '' }}
/>
<p>Selected: {this.theme || '(none)'}</p>
<Switch
label="Dark mode"
checked={this.darkMode}
onCheckedChange={(d: any) => { this.darkMode = d.checked }}
/>
<Slider
label="Volume"
value={[this.volume]}
min={0}
max={100}
onValueChange={(d: any) => { this.volume = d.value[0] }}
/>
</div>
)
}
}ToastStore<Toaster />import { Component } from '@geajs/core'
import { Button, Toaster, ToastStore } from '@geajs/ui'
export default class App extends Component {
save() {
ToastStore.success({ title: 'Saved!', description: 'Changes persisted.' })
}
template() {
return (
<div>
<Button click={this.save}>Save</Button>
<Toaster />
</div>
)
}
}ToastStore.success(opts).error(opts).info(opts).loading(opts).create(opts).dismiss(id?)<Dialog title="Confirm" description="Are you sure?" triggerLabel="Open">
<p>Dialog body content goes here.</p>
</Dialog><Tabs
defaultValue="account"
items={[
{ value: 'account', label: 'Account', content: <p>Account settings</p> },
{ value: 'security', label: 'Security', content: <p>Security settings</p> },
]}
/><Card>
<CardHeader>
<CardTitle>Profile</CardTitle>
<CardDescription>Update your details</CardDescription>
</CardHeader>
<CardContent>
<Label htmlFor="name">Name</Label>
<Input inputId="name" placeholder="Enter your name" value={this.name} />
</CardContent>
<CardFooter>
<Button click={this.save}>Save</Button>
</CardFooter>
</Card>:root {
--primary: 222 47% 11%;
--primary-foreground: 210 40% 98%;
--radius: 0.75rem;
}dark<html><html class="dark">--background--foreground-foreground--primary--secondary--muted--accent--destructive--card--popover--border--input--ring--dialog-background--radiusclassdata-partdata-state.select-trigger[data-state="open"] { border-color: hsl(var(--ring)); }
.switch-control[data-state="checked"] { background: hsl(var(--primary)); }ZagComponentimport * as myWidget from '@zag-js/my-widget'
import { normalizeProps } from '@zag-js/vanilla'
import { ZagComponent } from '@geajs/ui'
import type { SpreadMap } from '@geajs/ui'
export default class MyWidget extends ZagComponent {
declare open: boolean
createMachine() { return myWidget.machine }
getMachineProps(props: any) {
return {
id: this.id,
// map Gea props → Zag machine props
onOpenChange: (d: any) => { this.open = d.open; props.onOpenChange?.(d) },
}
}
connectApi(service: any) {
return myWidget.connect(service, normalizeProps)
}
getSpreadMap(): SpreadMap {
return {
'[data-part="root"]': 'getRootProps',
'[data-part="trigger"]': 'getTriggerProps',
'[data-part="content"]': 'getContentProps',
}
}
syncState(api: any) { this.open = api.open }
template(props: any) {
return (
<div data-part="root">
<button data-part="trigger">Toggle</button>
<div data-part="content">{props.children}</div>
</div>
)
}
}SpreadMap(api, el) => propsZagComponentspreadPropscnclsxtailwind-mergeimport { cn } from '@geajs/ui'
const cls = cn('px-4 py-2', active && 'bg-primary', className)