SutraUI (Sutra UI v0.4.0)

View Source

Sutra UI - We define the rules, so you don't have to.

A pure Phoenix LiveView UI component library with 55 components, CSS-first theming, and colocated JavaScript hooks. Built for Phoenix 1.8+ and Phoenix LiveView 1.2+ with Tailwind CSS v4.

Quick Start

# mix.exs
{:sutra_ui, "~> 0.4.0"}

# lib/my_app_web.ex
defp html_helpers do
  quote do
    use SutraUI
  end
end

# assets/css/app.css
@import "tailwindcss";
@source "../../deps/sutra_ui/lib";
@import "../../deps/sutra_ui/priv/static/sutra_ui.css";

See the Installation Guide for detailed setup instructions.

Requirements

DependencyVersionNotes
Elixir1.20+Matches the package constraint
Phoenix1.8+Required for colocated hooks
Phoenix LiveView1.2+Current supported LiveView line
Tailwind CSSv4CSS-first configuration

Why Phoenix 1.8+?

Sutra UI uses colocated hooks - JavaScript hooks defined alongside components. Runtime hooks need no app-side hook file; extracted hooks such as dialog and animated response are merged into LiveSocket.

Components by Category

Foundation

Basic building blocks for any interface.

ComponentDescription
SutraUI.ButtonButtons with 6 variants and 4 sizes
SutraUI.BadgeStatus indicators
SutraUI.SpinnerLoading indicators
SutraUI.KbdKeyboard shortcut display

Form Controls

Complete form toolkit with validation support.

ComponentDescription
SutraUI.InputText, email, password, number, date inputs
SutraUI.TextareaMulti-line text input
SutraUI.CheckboxCheckbox input
SutraUI.SwitchToggle switch
SutraUI.RadioGroupRadio button groups
SutraUI.SelectSearchable dropdown (hook)
SutraUI.SliderRange slider (hook)
SutraUI.RangeSliderDual-handle range (hook)
SutraUI.LiveSelectLiveComponent async searchable select (hook)
SutraUI.LabelForm labels
SutraUI.SimpleFormForm with auto-styling
SutraUI.InputGroupInput with prefix/suffix
SutraUI.InputOTPOne-time password inputs (hook)
SutraUI.FileUploadLiveView upload dropzone
SutraUI.FilterBarFilter controls layout

Layout

Structure and organize content.

ComponentDescription
SutraUI.CardContent container
SutraUI.HeaderPage headers
SutraUI.TableData tables
SutraUI.ItemList items
SutraUI.DrawerNavigation drawer (hook)
SutraUI.StepperMulti-step progress indicators
SutraUI.StepperWizardMulti-step wizard shell
SutraUI.TreeViewHierarchical navigation trees

Feedback

Communicate status and progress.

ComponentDescription
SutraUI.AlertAlert messages
SutraUI.FlashPhoenix flash messages
SutraUI.ToastToast notifications (hook)
SutraUI.ProgressProgress bars
SutraUI.SkeletonLoading placeholders
SutraUI.EmptyEmpty states
SutraUI.LoadingStateLoading indicators

Overlay

Layered UI elements.

ComponentDescription
SutraUI.DialogModal dialogs (hook)
SutraUI.PopoverClick-triggered popups (hook)
SutraUI.TooltipHover and focus tooltips (hook)
SutraUI.DropdownMenuDropdown menus (hook)
SutraUI.ContextMenuRight-click action menus (hook)
SutraUI.HoverCardHover preview cards (hook)
SutraUI.CommandCommand palette (hook)

Navigation

Help users move through your app.

ComponentDescription
SutraUI.TabsTab panels (hook)
SutraUI.AccordionCollapsible sections
SutraUI.BreadcrumbBreadcrumb trails
SutraUI.PaginationPage navigation
SutraUI.TabNavRouted tab-style navigation

Display

Present content and media.

ComponentDescription
SutraUI.AvatarUser avatars
SutraUI.CarouselImage carousels (hook)
SutraUI.ThemeSwitcherLight/dark theme event button (hook)
SutraUI.SeparatorVisual content dividers
SutraUI.MarqueeScrolling content banners
SutraUI.CalendarMonthly calendar grid
SutraUI.TimelineChronological event lists

AI

Composable primitives for AI-assisted interfaces.

ComponentDescription
SutraUI.ResponseText responses with reveal styles, or streamed Markdown
SutraUI.ActivitySafe user-facing agent progress with slot-owned rows

Theming

Sutra UI uses CSS variables compatible with shadcn/ui themes.

:root {
  --primary: oklch(0.65 0.20 260);
  --primary-foreground: oklch(0.98 0 0);
}

See the Theming Guide for complete customization options.

Accessibility

Sutra UI components use accessibility patterns appropriate to their behavior:

  • Semantic HTML elements
  • ARIA roles and attributes for composite widgets
  • Keyboard navigation for interactive components
  • Focus management where applicable
  • Screen reader support for status-style components

See the Accessibility Guide for details.

Guides

Quick Reference

Summary

Functions

Use Sutra UI in your Phoenix application.

Functions

__using__(opts)

(macro)

Use Sutra UI in your Phoenix application.

This macro imports Sutra UI function components for use in your templates. SutraUI.LiveSelect is a LiveComponent; render it with <.live_component module={SutraUI.LiveSelect} ... />. The macro imports its decode/1 and normalize_options/1 helpers.

Example

defmodule MyAppWeb do
  def html_helpers do
    quote do
      use SutraUI
    end
  end
end