Explains a plan limit and offers what to do next.
New workflows: 5 of 5 workflows used.
Free includes 5 workflows. Team has no limit, and adds paths and version history.
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { Gate } from "./ui/uicontext/components/kit/Gate.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 32rem)" } })const Message = UiSchema.TaggedEnum({ Asked: {} })export const WorkflowLimit = Html.component({ name: "WorkflowLimit", model: Schema.Boolean, message: Message,}).make({ init: () => false, update: { Asked: () => true }, view: (h, asked) => h.div.attrs(sx(styles.frame)).children( Gate(h, { props: { agentId: "gate-workflows", feature: "New workflows", kind: "limit", limit: { used: 5, limit: 5, unit: "workflows" }, needs: "the Team plan", detail: "Free includes 5 workflows. Team has no limit, and adds paths and version history.", status: asked ? "requested" : "locked", action: { label: "Ask an admin to upgrade" }, secondary: { label: "Compare plans", href: "#plans" }, }, onEmit: { RequestedAction: () => Message.Asked(), RequestedSecondary: () => undefined }, }), ),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/gateUsage
import { Gate } from "./ui/uicontext/components/kit/Gate.ts"const Message = UiSchema.TaggedEnum({ ClickedUpgrade: {} })export const SeatLimit = (h: Html.H<typeof Message.Type>, used: number, limit: number) => Gate(h, { props: { feature: "Inviting members", kind: "limit", limit: { used, limit, unit: "seats" }, needs: "more seats", action: { label: "Add seats" }, }, onEmit: { RequestedAction: () => Message.ClickedUpgrade(), RequestedSecondary: () => undefined }, })Examples
Banner and inline
A banner over a screen when a limit stops work; one line beside a control a role keeps from this person.
Runs: 20,000 of 20,000 tasks used.
New runs are paused until Dec 1. Running work finishes.
import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { Gate } from "./ui/uicontext/components/kit/Gate.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { space } from "./ui/uicontext/components/tokens.stylex.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 40rem)", display: "flex", flexDirection: "column", gap: space.lg } })export const GateLayouts = Html.component({ name: "GateLayouts", model: Schema.Struct({}), message: Schema.Never,}).make({ init: () => ({}), update: ($) => $.model, view: (h) => h.div.attrs(sx(styles.frame)).children( Gate(h, { key: "banner", props: { agentId: "gate-banner", feature: "Runs", kind: "limit", limit: { used: 20_000, limit: 20_000, unit: "tasks" }, detail: "New runs are paused until Dec 1. Running work finishes.", action: { label: "Upgrade" }, layout: "banner", }, onEmit: { RequestedAction: () => undefined, RequestedSecondary: () => undefined }, }), Gate(h, { key: "role", props: { agentId: "gate-inline", feature: "Publishing", kind: "role", needs: "an admin", layout: "inline", }, onEmit: { RequestedAction: () => undefined, RequestedSecondary: () => undefined }, }), ),})API reference
Props
| Name | Type | Description |
|---|---|---|
agentId | string | This gate's id for agents, unique on the page: "gate-private-teams" |
featurerequired | string | What is gated, as a noun phrase: "Private teams" |
kindrequired | "plan" | "addon" | "role" | "region" | "limit" | "waitlist" | What kind of gate, for the default sentence |
needs | string | What lifts it, as the sentence's object: "the Business plan", "an admin", "the AI add-on" |
limit | { used, limit, unit } | For a limit: the count against it |
status | "locked" | "requested" | "waitlisted" | "invited" | Where the person stands: locked, asked an admin already, on the waitlist, or invited |
sentence | string | Replaces the default sentence |
detail | string | A second line: what the plan adds, or when the limit resets |
action | GateAction | The next step: "Upgrade", "Ask an admin", "Join the waitlist" |
secondary | GateAction | A second, quieter step: "Compare plans" |
layout | "card" | "banner" | "inline" | A card in place of the feature, a banner over a screen, or one line beside a control |
Events
| Event | Payload | Description |
|---|---|---|
RequestedAction | {} | The next step was pressed: upgrade, ask an admin, join the waitlist |
RequestedSecondary | {} | The second step was pressed |
Agent actions
| Action | Description |
|---|---|
ClickedAction | Take the gate's next step (its action: upgrade, ask an admin, join a waitlist) |
ClickedSecondary | Take the gate's second step (its secondary) |
Accessibility
- The prompt is a note beside the feature, or a named region over a screen, with its next step as a real button or link.