Skip to content

The Open Standard for Generative UI

2.3 KB
Raw Blame
root = Stack([title, tabs], "column", "l")
title = TextContent("User Settings", "large-heavy")
tabs = Tabs([tabProfile, tabSecurity, tabNotifications])

tabProfile = TabItem("profile", "Profile", profileContent)
profileContent = [profileCard]
profileCard = Card([profileHeader, profileForm], "card")
profileHeader = CardHeader("Profile", "Update your personal information and avatar.")
profileForm = Form("profile_update", [nameField, avatarField], profileButtons)
nameField = FormControl("Display name", Input("display_name", "e.g., Alex Johnson", "text", ["required", "minLength:2", "maxLength:60"]))
avatarField = FormControl("Avatar URL", Input("avatar_url", "https://example.com/avatar.png", "url", ["url"]))
profileButtons = Buttons([saveProfileBtn, resetProfileBtn])
saveProfileBtn = Button("Save changes", "submit:profile_update", "primary")
resetProfileBtn = Button("Reset", "action:reset_profile_form", "secondary")

tabSecurity = TabItem("security", "Security", securityContent)
securityContent = [securityCard]
securityCard = Card([securityHeader, securityToggles, securityHint], "card")
securityHeader = CardHeader("Security", "Manage sign-in protection and account security.")
securityToggles = SwitchGroup([twoFaSwitch], "sunk")
twoFaSwitch = SwitchItem("Two-factor authentication (2FA)", "Require a verification code when signing in.", "two_fa", "enabled", false, true, false)
securityHint = TextCallout("info", "Tip", "After enabling 2FA, you may be asked to set up an authenticator app or backup codes.")

tabNotifications = TabItem("notifications", "Notifications", notificationsContent)
notificationsContent = [notificationsCard]
notificationsCard = Card([notificationsHeader, notificationsToggles], "card")
notificationsHeader = CardHeader("Notifications", "Choose what you want to be notified about.")
notificationsToggles = SwitchGroup([emailSwitch, productSwitch, securityAlertsSwitch], "sunk")
emailSwitch = SwitchItem("Email notifications", "Receive updates and account messages by email.", "notif_email", "enabled", true, true, false)
productSwitch = SwitchItem("Product updates", "Get notified about new features and improvements.", "notif_product", "enabled", false, false, false)
securityAlertsSwitch = SwitchItem("Security alerts", "Important alerts about sign-ins and security changes.", "notif_security", "enabled", true, true, false)