SutraUI (Sutra UI v0.3.0)

View Source

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

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

Quick Start

# mix.exs
{:sutra_ui, "~> 0.3.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.14+
Phoenix1.8+Required for colocated hooks
Phoenix LiveView1.1+ColocatedHook support
Tailwind CSSv4CSS-first configuration

Why Phoenix 1.8+?

Sutra UI uses colocated hooks - JavaScript hooks defined alongside components. No separate hooks.js file needed.

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.LiveSelectAsync searchable select (hook)
SutraUI.LabelForm labels
SutraUI.SimpleFormForm with auto-styling
SutraUI.InputGroupInput with prefix/suffix
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)

Feedback

Communicate status and progress.

ComponentDescription
SutraUI.AlertAlert 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 tooltips (CSS-only)
SutraUI.DropdownMenuDropdown menus (hook)
SutraUI.CommandCommand palette (hook)

Navigation

Help users move through your app.

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

Display

Present content and media.

ComponentDescription
SutraUI.AvatarUser avatars
SutraUI.CarouselImage carousels (hook)
SutraUI.ThemeSwitcherLight/dark toggle (hook)

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

All components follow WAI-ARIA patterns with:

  • Semantic HTML elements
  • Keyboard navigation
  • Focus management
  • Screen reader support

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 all available Sutra UI components for use in your templates.

Example

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